Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ped Spawner, Drunkness, NPC Ignore, Ragdoll, and Fix Metric Blocking #81

Merged
merged 4 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/game/features/self/Drunk.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "core/commands/LoopedCommand.hpp"
#include "core/frontend/Notifications.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Natives.hpp"


namespace YimMenu::Features
{
class Drunk : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

virtual void OnTick() override
{
AUDIO::SET_PED_IS_DRUNK(Self::PlayerPed, true);
PED::_SET_PED_DRUNKNESS(Self::PlayerPed, true, 1.0f);
}

virtual void OnDisable() override
{
if (PED::_GET_PED_DRUNKNESS(Self::PlayerPed))
{
AUDIO::SET_PED_IS_DRUNK(Self::PlayerPed, false);
PED::_SET_PED_DRUNKNESS(Self::PlayerPed, false, 0.0f);
}
}
};

static Drunk _Drunk{"drunk", "Drunk", "Sets the player to be drunk"};
}
25 changes: 25 additions & 0 deletions src/game/features/self/NPCIgnore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "core/commands/LoopedCommand.hpp"
#include "core/frontend/Notifications.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Natives.hpp"


namespace YimMenu::Features
{
class NPCIgnore : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

virtual void OnTick() override
{
PLAYER::SET_EVERYONE_IGNORE_PLAYER(Self::Id, true);
}

virtual void OnDisable() override
{
PLAYER::SET_EVERYONE_IGNORE_PLAYER(Self::Id, false);
}
};

static NPCIgnore _NPCIgnore{"npcignore", "NPC Ignore", "NPCs completely ignore this player!"};
}
2 changes: 2 additions & 0 deletions src/game/frontend/submenus/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "game/pointers/Pointers.hpp"



namespace YimMenu::Submenus
{
Network::Network() :
Expand All @@ -20,6 +21,7 @@ namespace YimMenu::Submenus
session->AddItem(std::make_shared<CommandItem>("explodeall"_J));
session->AddItem(std::make_shared<CommandItem>("maxhonorall"_J));
session->AddItem(std::make_shared<CommandItem>("minhonorall"_J));
session->AddItem(std::make_shared<BoolCommandItem>("blockalltelemetry"_J));
spoofing->AddItem(std::make_shared<BoolCommandItem>("hidegod"_J));
spoofing->AddItem(std::make_shared<BoolCommandItem>("voicechatoverride"_J));
AddCategory(std::move(session));
Expand Down
1 change: 1 addition & 0 deletions src/game/frontend/submenus/Players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <string>



// remove after testing
#include "core/frontend/Notifications.hpp"
#include "game/backend/FiberPool.hpp"
Expand Down
45 changes: 40 additions & 5 deletions src/game/frontend/submenus/Self.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
#include "core/commands/BoolCommand.hpp"
#include "core/commands/Commands.hpp"
#include "game/backend/FiberPool.hpp"
#include "game/backend/Players.hpp"
#include "game/backend/ScriptMgr.hpp"
#include "game/features/Features.hpp"
#include "game/frontend/items/Items.hpp"
#include "game/rdr/Natives.hpp"
#include "util/PedModels.hpp"
#include "util/SpawnPed.cpp"
#include "util/Rewards.hpp"

#include <map>
Expand Down Expand Up @@ -54,11 +58,12 @@ namespace YimMenu::Submenus
Self::Self() :
Submenu::Submenu("Self")
{
auto main = std::make_shared<Category>("Main");
auto globalsGroup = std::make_shared<Group>("Globals", GetListBoxDimensions());
auto movementGroup = std::make_shared<Group>("Movement", GetListBoxDimensions());
auto toolsGroup = std::make_shared<Group>("Tools", GetListBoxDimensions());
auto columns = std::make_shared<Column>(2);
auto main = std::make_shared<Category>("Main");
auto globalsGroup = std::make_shared<Group>("Globals", GetListBoxDimensions());
auto movementGroup = std::make_shared<Group>("Movement", GetListBoxDimensions());
auto toolsGroup = std::make_shared<Group>("Tools", GetListBoxDimensions());
auto pedSpawnerGroup = std::make_shared<Group>("Ped Spawner", GetListBoxDimensions());
auto columns = std::make_shared<Column>(2);


globalsGroup->AddItem(std::make_shared<BoolCommandItem>("godmode"_J));
Expand All @@ -74,9 +79,12 @@ namespace YimMenu::Submenus
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("keepclean"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("antilasso"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("antihogtie"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("voicechatoverride"_J)); // TODO: move this to spoofing or network
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("drunk"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("autotp"_J));
globalsGroup->AddItem(std::make_shared<BoolCommandItem>("superjump"_J));


toolsGroup->AddItem(std::make_shared<CommandItem>("suicide"_J));
toolsGroup->AddItem(std::make_shared<CommandItem>("clearcrimes"_J));
toolsGroup->AddItem(std::make_shared<ImGuiItem>([] {
Expand All @@ -85,15 +93,42 @@ namespace YimMenu::Submenus
ENTITY::FREEZE_ENTITY_POSITION(YimMenu::Self::PlayerPed, false);
});
}));

toolsGroup->AddItem(std::make_shared<BoolCommandItem>("npcignore"_J));
toolsGroup->AddItem(std::make_shared<CommandItem>("spawnwagon"_J));

movementGroup->AddItem(std::make_shared<BoolCommandItem>("noclip"_J));
static std::string ped_model_buf;
pedSpawnerGroup->AddItem(std::make_shared<ImGuiItem>([&]() {
ImGui::Text(std::string("Current Model: ").append(ped_model_buf).c_str());
ImGui::NewLine();

if (ImGui::BeginCombo("Ped Types", ped_model_buf.c_str()))
{
for (const auto& pedItem : pedModelInfos)
{
bool is_selected = (ped_model_buf == pedItem.model);
if (ImGui::Selectable(pedItem.model.c_str(), is_selected))
{
ped_model_buf = pedItem.model;
}
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}));
pedSpawnerGroup->AddItem(std::make_shared<ImGuiItem>([&] {
if (ImGui::Button("Spawn Ped"))
SpawnPed(ped_model_buf, YimMenu::Self::Id, YimMenu::Self::PlayerPed);
}));


columns->AddItem(globalsGroup);
columns->AddItem(toolsGroup);
columns->AddNextColumn();
columns->AddItem(movementGroup);
columns->AddItem(pedSpawnerGroup);
main->AddItem(columns);
AddCategory(std::move(main));

Expand Down
11 changes: 10 additions & 1 deletion src/game/hooks/Anticheat/SendMetric.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#include "core/commands/BoolCommand.hpp"
#include "core/commands/Commands.hpp"
#include "core/hooking/DetourHook.hpp"
#include "game/hooks/Hooks.hpp"
#include "unordered_set"

#include <rage/rlJson.hpp>
#include <rage/rlMetric.hpp>


namespace YimMenu::Features
{
BoolCommand _LogMetrics("logmetrics", "Log Metrics", "Log game telemetry");
BoolCommand _BlockAllTelemetry("blockalltelemetry", "Block All Telemetry", "Block all game telemetry");
}

namespace YimMenu::Hooks
Expand All @@ -29,6 +32,12 @@ namespace YimMenu::Hooks

if (Features::_LogMetrics.GetState())
LOG(INFO) << "METRIC: " << metric_name << "; DATA: " << serializer.GetBuffer();
return true;

if (Features::_BlockAllTelemetry.GetState())
{
return true;
}

return BaseHook::Get<Anticheat::SendMetric, DetourHook<decltype(&Anticheat::SendMetric)>>()->Original()(manager, metric);
Rxann marked this conversation as resolved.
Show resolved Hide resolved
}
}
14 changes: 14 additions & 0 deletions src/util/PedModels.hpp

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions src/util/SpawnPed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "core/frontend/Notifications.hpp"
#include "game/backend/FiberPool.hpp"
#include "game/backend/ScriptMgr.hpp"
#include "game/rdr/Natives.hpp"


namespace YimMenu
{
bool SpawnPed(std::string model_name, Player player, int playerPed)
{
FiberPool::Push([=] {
Hash model = MISC::GET_HASH_KEY(model_name.c_str());
DayibBaba marked this conversation as resolved.
Show resolved Hide resolved
if (STREAMING::IS_MODEL_IN_CDIMAGE(model) && STREAMING::IS_MODEL_VALID(model))
{
if (!STREAMING::HAS_MODEL_LOADED(model))
Rxann marked this conversation as resolved.
Show resolved Hide resolved
{
STREAMING::REQUEST_MODEL(model, false);
ScriptMgr::Yield();
}

Vector3 coords = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 3.0, -0.3);
float playerRotation = ENTITY::GET_ENTITY_ROTATION(playerPed, 2).x;
auto ped = PED::CREATE_PED(model, coords.x, coords.y, coords.z, playerRotation, 0, 0, 0, 0);

ScriptMgr::Yield();
PED::_SET_RANDOM_OUTFIT_VARIATION(ped, true);
ENTITY::SET_ENTITY_ALPHA(ped, 255, 0);
ENTITY::SET_ENTITY_VISIBLE(ped, true);
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model);
NETWORK::NETWORK_REGISTER_ENTITY_AS_NETWORKED(ped);

int id = NETWORK::PED_TO_NET(ped);
if (NETWORK::NETWORK_DOES_NETWORK_ID_EXIST(id))
{
ENTITY::SET_ENTITY_SHOULD_FREEZE_WAITING_ON_COLLISION(ped, true);
if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(ped))
{
NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(id, true);
NETWORK::IS_NETWORK_ID_OWNED_BY_PARTICIPANT(id);
}
}
return true;
}
Rxann marked this conversation as resolved.
Show resolved Hide resolved
return false;
});
return false;
}
}
Loading