Skip to content

Commit

Permalink
Bump RDR-Classes, Features, Protection Improvements, Casing Changes (#…
Browse files Browse the repository at this point in the history
…163)

* Bump RDR-Classes, Features, Protection Improvements,

* Update increase bounty

* Update

* Casing fixes, removed duplicate autotp command

* Ticker event

* Update, not done

* Add missing command to menu

* Fix horrid indention (thank you github)

* Added some more stuff

* Removed double include

* Fix indent

* Untested pool overflow protection

* fix githubs mistakes

* uh. fix ci?

* fix ci
  • Loading branch information
tyackman authored Jul 18, 2024
1 parent 2b195ef commit 5456c7f
Show file tree
Hide file tree
Showing 52 changed files with 609 additions and 187 deletions.
4 changes: 3 additions & 1 deletion cmake/async-logger.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
include(FetchContent)

add_compile_definitions(CXX_FORMAT_SUPPORT)

message(STATUS "Setting up AsyncLogger")
FetchContent_Declare(
AsyncLogger
GIT_REPOSITORY https://github.com/Yimura/AsyncLogger.git
GIT_TAG v0.0.6
GIT_TAG 6fcfd90b3f4ca4dae09c4a96e9a506e6aea06472
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(AsyncLogger)
Expand Down
2 changes: 1 addition & 1 deletion cmake/rdr-classes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
rdr_classes
GIT_REPOSITORY https://github.com/YimMenu/RDR-Classes.git
GIT_TAG 9ef64d85290f85ddfa6a4b6a8ef1d9acfcb31808
GIT_TAG 7c78535a483e85fc714525ddce330b2e776e9b8f
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
1 change: 1 addition & 0 deletions src/core/hooking/Hooking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace YimMenu
BaseHook::Add<Hooks::Protections::SerializeServerRPC>(new DetourHook("SerializeServerRPC", Pointers.SerializeServerRPC, Hooks::Protections::SerializeServerRPC));
BaseHook::Add<Hooks::Protections::ReceiveServerMessage>(new DetourHook("ReceiveServerMessage", Pointers.ReceiveServerMessage, Hooks::Protections::ReceiveServerMessage));
BaseHook::Add<Hooks::Protections::ReceiveArrayUpdate>(new DetourHook("ReceiveArrayUpdate", Pointers.ReceiveArrayUpdate, Hooks::Protections::ReceiveArrayUpdate));
BaseHook::Add<Hooks::Protections::CreatePoolItem>(new DetourHook("CreatePoolItem", Pointers.CreatePoolItem, Hooks::Protections::CreatePoolItem));

BaseHook::Add<Hooks::Voice::EnumerateAudioDevices>(new DetourHook("EnumerateAudioDevices", Pointers.EnumerateAudioDevices, Hooks::Voice::EnumerateAudioDevices));
BaseHook::Add<Hooks::Voice::DirectSoundCaptureCreate>(new DetourHook("DirectSoundCaptureCreate", Pointers.DirectSoundCaptureCreate, Hooks::Voice::DirectSoundCaptureCreate));
Expand Down
42 changes: 42 additions & 0 deletions src/core/misc/RateLimiter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once
#include <chrono>

namespace YimMenu
{
class RateLimiter
{
uint32_t m_AttemptsAllowedInTimePeriod;
std::chrono::milliseconds m_TimePeriod;
std::chrono::system_clock::time_point m_LastEventTime{};
uint32_t m_NumAttemptsAllowed = 0;

public:
RateLimiter(std::chrono::milliseconds period, uint32_t numAllowedAttempts) :
m_AttemptsAllowedInTimePeriod(numAllowedAttempts),
m_TimePeriod(period)
{
}

// Returns true if the rate limit has been exceeded
bool Process()
{
if (std::chrono::system_clock::now() - m_LastEventTime < m_TimePeriod)
{
if (++m_NumAttemptsAllowed > m_AttemptsAllowedInTimePeriod)
return true;
}
else
{
m_LastEventTime = std::chrono::system_clock::now();
m_NumAttemptsAllowed = 1;
}
return false;
}

// Check if the rate limit was exceeded by the last process() call. Use this to prevent the player from being flooded with notifications
bool ExceededLastProcess()
{
return (m_NumAttemptsAllowed - 1) == m_AttemptsAllowedInTimePeriod;
}
};
}
14 changes: 14 additions & 0 deletions src/game/backend/Players.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ namespace YimMenu
return GetInstance().m_PlayerDatas[idx];
}

static Player GetRandom()
{
auto& players = GetPlayers();

if (players.empty())
{
return Player((uint8_t)0);
}

uint8_t random = static_cast<uint8_t>(rand() % players.size());
auto it = std::next(players.begin(), random);
return it->second;
}

private:
static Players& GetInstance()
{
Expand Down
50 changes: 25 additions & 25 deletions src/game/features/Features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,31 @@ namespace YimMenu
{
if (GUI::IsOpen())
{
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_LOOK_LR, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_LOOK_UD, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_MELEE_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_DRIVE_LOOK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_HORSE_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_HORSE_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_HORSE_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_HORSE_GUN_LR, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_HORSE_GUN_UD, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_DRIVE_LOOK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_NEXT_WEAPON, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_PREV_WEAPON, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_CAR_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_CAR_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_CAR_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_CAR_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_BOAT_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_BOAT_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)eNativeInputs::INPUT_VEH_BOAT_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_LOOK_LR, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_LOOK_UD, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_MELEE_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_DRIVE_LOOK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_HORSE_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_HORSE_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_HORSE_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_HORSE_GUN_LR, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_HORSE_GUN_UD, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_DRIVE_LOOK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_NEXT_WEAPON, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_PREV_WEAPON, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_CAR_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_CAR_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_CAR_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_CAR_ATTACK2, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_BOAT_AIM, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_BOAT_ATTACK, 1);
PAD::DISABLE_CONTROL_ACTION(0, (Hash)NativeInputs::INPUT_VEH_BOAT_ATTACK2, 1);
}

ScriptMgr::Yield();
Expand Down
2 changes: 1 addition & 1 deletion src/game/features/mount/KeepHorseClean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace YimMenu::Features
{
if (auto mount = Self::GetMount())
{
PED::_SET_PED_DAMAGE_CLEANLINESS(mount.GetHandle(), (int)ePedDamageCleanliness::PED_DAMAGE_CLEANLINESS_PERFECT);
PED::_SET_PED_DAMAGE_CLEANLINESS(mount.GetHandle(), (int)PedDamageCleanliness::PED_DAMAGE_CLEANLINESS_PERFECT);
PED::CLEAR_PED_WETNESS(mount.GetHandle());
PED::CLEAR_PED_ENV_DIRT(mount.GetHandle());
PED::CLEAR_PED_BLOOD_DAMAGE(mount.GetHandle());
Expand Down
8 changes: 4 additions & 4 deletions src/game/features/mount/KeepHorseCoresFilled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace YimMenu::Features
if (!mount || mount.IsDead())
return;

auto health_core = ATTRIBUTE::_GET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)eAttributeCore::ATTRIBUTE_CORE_HEALTH);
auto stamina_care = ATTRIBUTE::_GET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)eAttributeCore::ATTRIBUTE_CORE_STAMINA);
auto health_core = ATTRIBUTE::_GET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)AttributeCore::ATTRIBUTE_CORE_HEALTH);
auto stamina_care = ATTRIBUTE::_GET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)AttributeCore::ATTRIBUTE_CORE_STAMINA);

if (health_core < 100)
ATTRIBUTE::_SET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)eAttributeCore::ATTRIBUTE_CORE_HEALTH, 100);
ATTRIBUTE::_SET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)AttributeCore::ATTRIBUTE_CORE_HEALTH, 100);
if (stamina_care < 100)
ATTRIBUTE::_SET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)eAttributeCore::ATTRIBUTE_CORE_STAMINA, 100);
ATTRIBUTE::_SET_ATTRIBUTE_CORE_VALUE(mount.GetHandle(), (int)AttributeCore::ATTRIBUTE_CORE_STAMINA, 100);
}
};

Expand Down
15 changes: 10 additions & 5 deletions src/game/features/players/toxic/ActivateDefensiveMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@

namespace YimMenu::Features
{
void Defensive(Player player)
{
uint64_t data[13]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_FORCE_PASSIVE);
data[1] = player.GetId();
data[8] = 2;
Scripts::SendScriptEvent(data, 13, 43, 1 << player.GetId());
}

class ActivateDefensiveMode : public PlayerCommand
{
using PlayerCommand::PlayerCommand;

virtual void OnCall(Player player) override
{
uint64_t data[13]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_FORCE_PASSIVE);
data[1] = Self::GetPlayer().GetId();
data[8] = 2;
Scripts::SendScriptEvent(data, 13, 1 << player.GetId());
Defensive(player);
}
};

Expand Down
13 changes: 9 additions & 4 deletions src/game/features/players/toxic/ActivateOffensiveMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@

namespace YimMenu::Features
{
void Offensive(Player player)
{
uint64_t data[13]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_FORCE_NOT_PASSIVE_HORSE);
data[1] = player.GetId();
Scripts::SendScriptEvent(data, 13, 43, 1 << player.GetId());
}

class ActivateOffensiveMode : public PlayerCommand
{
using PlayerCommand::PlayerCommand;

virtual void OnCall(Player player) override
{
uint64_t data[13]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_FORCE_NOT_PASSIVE_HORSE);
data[1] = Self::GetPlayer().GetId();
Scripts::SendScriptEvent(data, 13, 1 << player.GetId());
Offensive(player);
}
};

Expand Down
31 changes: 31 additions & 0 deletions src/game/features/players/toxic/EndParlay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "game/backend/ScriptMgr.hpp"
#include "game/backend/Self.hpp"
#include "game/commands/PlayerCommand.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Scripts.hpp"

namespace YimMenu::Features
{
void ParlayEnd(Player player)
{
uint64_t data[7]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_PARLAY);
data[1] = player.GetId();
data[4] = 5;
data[5] = 11;
data[6] = 9;
Scripts::SendScriptEvent(data, 9, 10, 1 << player.GetId());
}

class EndParlay : public PlayerCommand
{
using PlayerCommand::PlayerCommand;

virtual void OnCall(Player player) override
{
ParlayEnd(player);
}
};

static EndParlay _EndParlay{"endparlay", "End Parlay", "End a parlay with the player", 0, false};
}
42 changes: 42 additions & 0 deletions src/game/features/players/toxic/IncreaseBounty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "game/backend/ScriptMgr.hpp"
#include "game/backend/Self.hpp"
#include "game/commands/PlayerCommand.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Scripts.hpp"

namespace YimMenu::Features
{
void AddBounty(Player player)
{
uint64_t data[13]{};
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_PRESS_CHARGES);
data[1] = player.GetId();
data[4] = 2;
data[5] = 5;
data[6] = 9;
data[11] = 1;
data[12] = 1;

for (int i = 0; i < 10; ++i)
{
for (int j = 0; j < 10; ++j)
{
Scripts::SendScriptEvent(data, 13, 7, 1 << player.GetId());
}

ScriptMgr::Yield();
}
}

class IncreaseBounty : public PlayerCommand
{
using PlayerCommand::PlayerCommand;

virtual void OnCall(Player player) override
{
AddBounty(player);
}
};

static IncreaseBounty _IncreaseBounty{"increasebounty", "Increase Bounty", "Increase the players bounty", 0, false};
}
15 changes: 8 additions & 7 deletions src/game/features/players/toxic/MaximumHonor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "game/commands/PlayerCommand.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Scripts.hpp"
#include "game/backend/ScriptMgr.hpp"
#include "game/backend/Self.hpp"
#include "game/commands/PlayerCommand.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Scripts.hpp"

namespace YimMenu::Features
{
// TODO: Refactor sender
void MaxHonor(int bits)
{
uint64_t data[7]{};
Expand All @@ -17,13 +18,13 @@ namespace YimMenu::Features
data[4] = 2;
data[5] = "PERSONA_HONOR_ACTION__FME_BOUNTY_RETURNED_ALIVE"_J;
data[6] = 1;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__HORSE_CARE"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__NB_KIDNAPPED_RESCUE"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__MISSION_POS_FIFTY"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
ScriptMgr::Yield(40ms);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/game/features/players/toxic/MinimumHonor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "game/backend/ScriptMgr.hpp"
#include "game/commands/PlayerCommand.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Scripts.hpp"
#include "game/commands/PlayerCommand.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Scripts.hpp"

namespace YimMenu::Features
{
// TODO: Refactor sender
void MinHonor(int bits)
{
uint64_t data[7]{};
Expand All @@ -17,13 +18,13 @@ namespace YimMenu::Features
data[4] = 2;
data[5] = "PERSONA_HONOR_ACTION__MISSION_NEG_FIFTY"_J;
data[6] = 1;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__MISSION_NEG_FORTYFIVE"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__MURDER_RAMPAGE"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
data[5] = "PERSONA_HONOR_ACTION__MURDER_BUTCHER"_J;
Scripts::SendScriptEvent(data, 13, bits);
Scripts::SendScriptEvent(data, 13, 6, bits);
ScriptMgr::Yield(40ms);
}
}
Expand Down
Loading

0 comments on commit 5456c7f

Please sign in to comment.