Skip to content

Commit

Permalink
Merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maybegreat48 committed Jul 15, 2024
1 parent 46041d0 commit c8b462e
Show file tree
Hide file tree
Showing 32 changed files with 250 additions and 135 deletions.
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 d62a02a6d7f0686148d638152c34a3856fa3248e
GIT_TAG 9ef64d85290f85ddfa6a4b6a8ef1d9acfcb31808
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
51 changes: 51 additions & 0 deletions src/core/commands/FloatCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "FloatCommand.hpp"
#include "game/backend/FiberPool.hpp" // TODO: game import in core

namespace YimMenu
{
void FloatCommand::OnCall()
{
}

void FloatCommand::SaveState(nlohmann::json& value)
{
value = m_State;
}

void FloatCommand::LoadState(nlohmann::json& value)
{
m_State = value;
}

FloatCommand::FloatCommand(std::string name, std::string label, std::string description, std::optional<float> min, std::optional<float> max, float def_val) :
Command(name, label, description, 0),
m_Min(min),
m_Max(max),
m_State(def_val)
{
}

float FloatCommand::GetState()
{
return m_State;
}

void FloatCommand::SetState(float state)
{
FiberPool::Push([this] {
OnChange();
});
m_State = state;
MarkDirty();
}

std::optional<float> FloatCommand::GetMinimum()
{
return m_Min;
}

std::optional<float> FloatCommand::GetMaximum()
{
return m_Max;
}
}
25 changes: 25 additions & 0 deletions src/core/commands/FloatCommand.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "Command.hpp"

namespace YimMenu
{
class FloatCommand : public Command
{
protected:
virtual void OnChange(){};
virtual void OnCall() override;
virtual void SaveState(nlohmann::json& value) override;
virtual void LoadState(nlohmann::json& value) override;

float m_State = 0;
std::optional<float> m_Min;
std::optional<float> m_Max;

public:
FloatCommand(std::string name, std::string label, std::string description, std::optional<float> min = std::nullopt, std::optional<float> max = std::nullopt, float def_val = 0.0f);
float GetState();
void SetState(float state);
std::optional<float> GetMinimum();
std::optional<float> GetMaximum();
};
}
7 changes: 5 additions & 2 deletions src/game/features/mount/HorseClimbSteepSlopes.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/rdr/Natives.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"

namespace YimMenu::Features
{
Expand All @@ -10,7 +10,10 @@ namespace YimMenu::Features

virtual void OnTick() override
{
PED::SET_PED_RESET_FLAG(Self::Mount, 204, true);
if (Self::GetMount())
{
PED::SET_PED_RESET_FLAG(Self::GetMount().GetHandle(), 204, true);
}
}
};

Expand Down
15 changes: 9 additions & 6 deletions src/game/features/mount/KeepHorseClean.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

Expand All @@ -11,11 +11,14 @@ namespace YimMenu::Features

virtual void OnTick() override
{
PED::_SET_PED_DAMAGE_CLEANLINESS(Self::Mount, (int)ePedDamageCleanliness::PED_DAMAGE_CLEANLINESS_PERFECT);
PED::CLEAR_PED_WETNESS(Self::Mount);
PED::CLEAR_PED_ENV_DIRT(Self::Mount);
PED::CLEAR_PED_BLOOD_DAMAGE(Self::Mount);
PED::CLEAR_PED_DAMAGE_DECAL_BY_ZONE(Self::Mount, 10, "ALL");
if (auto mount = Self::GetMount())
{
PED::_SET_PED_DAMAGE_CLEANLINESS(mount.GetHandle(), (int)ePedDamageCleanliness::PED_DAMAGE_CLEANLINESS_PERFECT);
PED::CLEAR_PED_WETNESS(mount.GetHandle());
PED::CLEAR_PED_ENV_DIRT(mount.GetHandle());
PED::CLEAR_PED_BLOOD_DAMAGE(mount.GetHandle());
PED::CLEAR_PED_DAMAGE_DECAL_BY_ZONE(mount.GetHandle(), 10, "ALL");
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/game/features/self/AutoCockWeapon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Natives.hpp"

namespace YimMenu::Features
Expand All @@ -10,7 +10,8 @@ namespace YimMenu::Features

virtual void OnTick() override
{
WEAPON::_SET_FORCE_CURRENT_WEAPON_INTO_COCKED_STATE(Self::PlayerPed, 0);
if (Self::GetPed())
WEAPON::_SET_FORCE_CURRENT_WEAPON_INTO_COCKED_STATE(Self::GetPed().GetHandle(), 0);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/game/features/self/AutoTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace YimMenu::Features

virtual void OnTick() override
{
if (MAP::IS_WAYPOINT_ACTIVE())
if (MAP::IS_WAYPOINT_ACTIVE() && Self::GetPed())
{
Vector3 coords = Teleport::GetWaypointCoords();
if (coords != Vector3{0, 0, 0})
Expand Down
20 changes: 11 additions & 9 deletions src/game/features/self/EagleEye.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "core/commands/LoopedCommand.hpp"
#include "core/frontend/Notifications.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

Expand All @@ -12,21 +12,23 @@ namespace YimMenu::Features

virtual void OnTick() override
{
if (!PLAYER::_IS_SECONDARY_SPECIAL_ABILITY_ACTIVE(YimMenu::Self::Id)) // Checks if Eagle Eye is active before toggling it on
auto id = YimMenu::Self::GetPlayer().GetId();
if (!PLAYER::_IS_SECONDARY_SPECIAL_ABILITY_ACTIVE(id)) // Checks if Eagle Eye is active before toggling it on
{
PLAYER::_SECONDARY_SPECIAL_ABILITY_SET_ACTIVE(YimMenu::Self::Id); // Toggles Eagle Eye on
PLAYER::_EAGLE_EYE_SET_PLUS_FLAG_DISABLED(YimMenu::Self::Id, false); // Allows running while eagle eye is active
PLAYER::_SECONDARY_SPECIAL_ABILITY_SET_ACTIVE(id); // Toggles Eagle Eye on
PLAYER::_EAGLE_EYE_SET_PLUS_FLAG_DISABLED(id, false); // Allows running while eagle eye is active
}
PLAYER::_MODIFY_INFINITE_TRAIL_VISION(YimMenu::Self::Id, 1); // Sets Eagle Eye to Infinite
PLAYER::_MODIFY_INFINITE_TRAIL_VISION(id, 1); // Sets Eagle Eye to Infinite
}

virtual void OnDisable() override
{
PLAYER::_SECONDARY_SPECIAL_ABILITY_SET_DISABLED(YimMenu::Self::Id, 1); // Disables Eagle Eye
PLAYER::_MODIFY_INFINITE_TRAIL_VISION(YimMenu::Self::Id, 0); // Turns off Infinite Eagle Eye
PLAYER::_EAGLE_EYE_SET_PLUS_FLAG_DISABLED(YimMenu::Self::Id, NULL); //Setting to truee breaks it, leave it at NULL
auto id = YimMenu::Self::GetPlayer().GetId();
PLAYER::_SECONDARY_SPECIAL_ABILITY_SET_DISABLED(id, 1); // Disables Eagle Eye
PLAYER::_MODIFY_INFINITE_TRAIL_VISION(id, 0); // Turns off Infinite Eagle Eye
PLAYER::_EAGLE_EYE_SET_PLUS_FLAG_DISABLED(id, false); // Setting to truee breaks it, leave it at false
}
};

static EagleEye _EagleEye{"eagleeye", "Eagle Eye", "Enables Infinite/Always Active Eagle Eye."};
static EagleEye _EagleEye{"eagleeye", "Eagle Eye", "Enables infinite/always active Eagle Eye"};
}
2 changes: 0 additions & 2 deletions src/game/features/self/NoRagdoll.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"

namespace YimMenu::Features
{
Expand Down
10 changes: 5 additions & 5 deletions src/game/features/self/NoSpread.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/rdr/Enums.hpp"
#include "game/rdr/Natives.hpp"
#include "game/backend/Self.hpp"

namespace YimMenu::Features
{
Expand All @@ -11,12 +9,14 @@ namespace YimMenu::Features

virtual void OnTick() override
{
PED::SET_PED_ACCURACY(Self::PlayerPed, 100);
if (Self::GetPed())
Self::GetPed().SetAccuracy(100);
}

virtual void OnDisable() override
{
PED::SET_PED_ACCURACY(Self::PlayerPed, 0); // Does not set it to miss every time, accuracy is weird.
if (Self::GetPed())
Self::GetPed().SetAccuracy(0);
}
};

Expand Down
29 changes: 0 additions & 29 deletions src/game/features/self/SuperDamage.cpp

This file was deleted.

13 changes: 8 additions & 5 deletions src/game/features/self/SuperRun.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "core/commands/LoopedCommand.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"
#include "game/rdr/Natives.hpp"

namespace YimMenu::Features
Expand All @@ -10,11 +10,14 @@ namespace YimMenu::Features

virtual void OnTick() override
{
if (PED::IS_PED_RAGDOLL(Self::PlayerPed))
return;
if (auto ped = Self::GetPed())
{
if (PED::IS_PED_RAGDOLL(ped.GetHandle()))
return;

if (TASK::IS_PED_RUNNING(Self::PlayerPed) || TASK::IS_PED_SPRINTING(Self::PlayerPed))
ENTITY::APPLY_FORCE_TO_ENTITY(Self::PlayerPed, 1, 0.0f, 20.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1, 1, 1, true, false, true);
if (TASK::IS_PED_RUNNING(ped.GetHandle()) || TASK::IS_PED_SPRINTING(ped.GetHandle()))
ENTITY::APPLY_FORCE_TO_ENTITY(ped.GetHandle(), 1, 0.0f, 20.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1, 1, 1, true, false, true);
}
}
};

Expand Down
19 changes: 13 additions & 6 deletions src/game/features/self/WhistleModifier.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#include "game/frontend/submenus/Self.hpp"
#include "core/commands/LoopedCommand.hpp"
#include "core/commands/FloatCommand.hpp"
#include "game/rdr/Natives.hpp"
#include "game/features/Features.hpp"
#include "game/backend/Self.hpp"

namespace YimMenu::Features
{
static FloatCommand _WhistlePitch{"whistlepitch", "Whistle Pitch", "The pitch of your whistle", 0.0f, 1.0f, 0.0f};
static FloatCommand _WhistleClarity{"whistleclarity", "Whistle Clarity", "The clarity of your whistle", 0.0f, 1.0f, 0.0f};
static FloatCommand _WhistleShape{"whistleshape", "Whistle Shape", "The shape of your whistle", 0.0f, 10.0f, 0.0f};

class WhistleOverride : public LoopedCommand
{
using LoopedCommand::LoopedCommand;

virtual void OnTick() override
{
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistlePitch", SelfStorage::pitch);
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistleClarity", SelfStorage::clarity);
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(Self::PlayerPed, "Ped.WhistleShape", SelfStorage::shape);
if (auto ped = Self::GetPed())
{
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistlePitch", _WhistlePitch.GetState());
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistleClarity", _WhistleClarity.GetState());
AUDIO::_SET_WHISTLE_CONFIG_FOR_PED(ped.GetHandle(), "Ped.WhistleShape", _WhistleShape.GetState());
}
}
};

static WhistleOverride _WhistleOverride{"overridewhistle", "Whistle Modifier", "Modify your whistle tone"};
static WhistleOverride _WhistleOverride{"overridewhistle", "Modify Whistles", "Modify your whistle tone"};
}
File renamed without changes.
4 changes: 2 additions & 2 deletions src/game/frontend/ESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace YimMenu
if (!plyr.IsValid() || !plyr.GetPed().IsValid() || plyr == Self::GetPlayer() || boneToScreen(plyr.GetPed().GetBonePosition(torsoBone)).x == 0)
return;

float distanceToPlayer = Math::DistanceBetweenVectors(Self::GetPed().GetPosition(), plyr.GetPed().GetBonePosition(torsoBone));
float distanceToPlayer = Self::GetPed().GetPosition().GetDistance(plyr.GetPed().GetBonePosition(torsoBone));
int alphaBasedOnDistance = 255;
ImColor colorBasedOnDistance = Red;

Expand All @@ -100,7 +100,7 @@ namespace YimMenu
drawList->AddText({boneToScreen(plyr.GetPed().GetBonePosition(headBone)).x,
boneToScreen(plyr.GetPed().GetBonePosition(headBone)).y + 20},
colorBasedOnDistance,
std::to_string((int)Math::DistanceBetweenVectors(Self::GetPed().GetPosition(), plyr.GetPed().GetBonePosition(torsoBone)))
std::to_string((int)Self::GetPed().GetPosition().GetDistance(plyr.GetPed().GetBonePosition(torsoBone)))
.data());

currentFont->Scale = originalFontSize;
Expand Down
42 changes: 42 additions & 0 deletions src/game/frontend/items/FloatCommandItem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "Items.hpp"
#include "core/commands/Command.hpp"
#include "core/commands/Commands.hpp"
#include "core/commands/FloatCommand.hpp"
#include "core/frontend/widgets/toggle/imgui_toggle.hpp"

namespace YimMenu
{
FloatCommandItem::FloatCommandItem(joaat_t id, std::optional<std::string> label_override) :
m_Command(Commands::GetCommand<FloatCommand>(id)),
m_LabelOverride(label_override)
{
}

void FloatCommandItem::Draw()
{
if (!m_Command)
{
ImGui::Text("Unknown!");
return;
}

auto value = m_Command->GetState();
auto label = m_LabelOverride.has_value() ? m_LabelOverride.value().c_str() : m_Command->GetLabel().c_str();
if (!m_Command->GetMinimum().has_value() || !m_Command->GetMaximum().has_value())
{
ImGui::SetNextItemWidth(150);
if (ImGui::InputFloat(label, &value))
{
m_Command->SetState(value);
}
}
else
{
ImGui::SetNextItemWidth(150);
if (ImGui::SliderFloat(label, &value, m_Command->GetMinimum().value(), m_Command->GetMaximum().value()))
{
m_Command->SetState(value);
}
}
}
}
Loading

0 comments on commit c8b462e

Please sign in to comment.