From dd6907bf14d213d6ac000f72072b73571176446f Mon Sep 17 00:00:00 2001 From: kurumimeow Date: Tue, 8 Jul 2025 03:50:20 +0530 Subject: [PATCH] feat: add custom weapons (#388) * added custom weapons * remove SameLineItem * some fixes * no changes * more fixes * some changes --- src/core/util/RainbowColor.hpp | 85 ++++ src/game/features/self/CustomWeapon.cpp | 381 ++++++++++++++++++ src/game/features/self/CustomWeapon.hpp | 72 ++++ src/game/frontend/items/ConditionalItem.cpp | 29 +- src/game/frontend/items/Items.hpp | 18 + src/game/frontend/items/TabBarItem.cpp | 22 + src/game/frontend/submenus/Debug/Scripts.cpp | 14 +- .../Recovery/Heist/ApartmentHeist.hpp | 1 + .../Recovery/Heist/CayoPericoHeist.cpp | 10 +- .../Recovery/Heist/CayoPericoHeist.hpp | 1 + .../Recovery/Heist/DiamondCasinoHeist.cpp | 43 +- .../Recovery/Heist/DiamondCasinoHeist.hpp | 1 + .../submenus/Recovery/Heist/DoomsdayHeist.hpp | 1 + .../submenus/Recovery/HeistModifier.cpp | 19 +- src/game/frontend/submenus/Self/Weapons.cpp | 46 ++- .../submenus/Vehicle/SpawnVehicle.cpp | 14 +- src/game/gta/RayCast.cpp | 66 +++ src/game/gta/RayCast.hpp | 19 + src/game/gta/Vehicle.cpp | 5 +- src/game/gta/Vehicle.hpp | 2 +- src/types/entity/DecalTypes.hpp | 57 +++ 21 files changed, 830 insertions(+), 76 deletions(-) create mode 100644 src/core/util/RainbowColor.hpp create mode 100644 src/game/features/self/CustomWeapon.cpp create mode 100644 src/game/features/self/CustomWeapon.hpp create mode 100644 src/game/frontend/items/TabBarItem.cpp create mode 100644 src/game/gta/RayCast.cpp create mode 100644 src/game/gta/RayCast.hpp create mode 100644 src/types/entity/DecalTypes.hpp diff --git a/src/core/util/RainbowColor.hpp b/src/core/util/RainbowColor.hpp new file mode 100644 index 0000000..e897693 --- /dev/null +++ b/src/core/util/RainbowColor.hpp @@ -0,0 +1,85 @@ +#pragma once + +namespace YimMenu +{ + struct Color + { + float r; + float g; + float b; + float a; + + Color(float red = 0.f, float green = 0.f, float blue = 0.f, float alpha = 255.f) : + r(red), + g(green), + b(blue), + a(alpha) + { + } + + Color(ImVec4 color) : + r(color.x), + g(color.y), + b(color.z), + a(color.w) + { + } + }; + + enum class RainbowColorStyle + { + Fade, + Spasm + }; + + inline void RainbowColor(Color& color, int speed = 1, RainbowColorStyle type = RainbowColorStyle::Fade) + { + static bool firstInit = true; + static std::chrono::system_clock::time_point lastRunTime; + + if (type == RainbowColorStyle::Spasm) + { + auto delay = std::chrono::milliseconds(std::max(10, 1010 - (speed * 100))); + + if (lastRunTime + delay < std::chrono::system_clock::now()) + { + color.r = rand() % 256; + color.g = rand() % 256; + color.b = rand() % 256; + + lastRunTime = std::chrono::system_clock::now(); + firstInit = true; + } + } + + if (type == RainbowColorStyle::Fade) + { + if (firstInit) + { + color.r = 255; + color.g = 0; + color.b = 0; + firstInit = false; + } + + if (color.r > 0 && color.b == 0) + { + color.g += speed; + color.r -= speed; + } + if (color.g > 0 && color.r == 0) + { + color.b += speed; + color.g -= speed; + } + if (color.b > 0 && color.g == 0) + { + color.r += speed; + color.b -= speed; + } + color.r = std::clamp(color.r, 0.f, 255.f); + color.g = std::clamp(color.g, 0.f, 255.f); + color.b = std::clamp(color.b, 0.f, 255.f); + } + } +} \ No newline at end of file diff --git a/src/game/features/self/CustomWeapon.cpp b/src/game/features/self/CustomWeapon.cpp new file mode 100644 index 0000000..3197096 --- /dev/null +++ b/src/game/features/self/CustomWeapon.cpp @@ -0,0 +1,381 @@ +#include "CustomWeapon.hpp" +#include "core/backend/FiberPool.hpp" +#include "core/backend/ScriptMgr.hpp" +#include "core/frontend/Notifications.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/Object.hpp" +#include "types/entity/DecalTypes.hpp" +#include "types/script/Timer.hpp" +#include "game/gta/RayCast.hpp" + +namespace YimMenu::Features +{ + void CustomWeapon::OnTick() + { + bool isCustomWeaponActionAllowed = !_CustomWeaponEnabledOnWeaponOut.GetState() || WEAPON::IS_PED_ARMED(Self::GetPed().GetHandle(), 4 | 2); + + if (!isCustomWeaponActionAllowed) + return; + + CustomWeapons selectedWeaponType = static_cast(_CustomWeaponType.GetState()); + + for (const auto& control : attackControls) + PAD::DISABLE_CONTROL_ACTION(0, static_cast(control), true); + + Entity m_Entity{nullptr}; + + switch (selectedWeaponType) + { + case CustomWeapons::CAGE_GUN: + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + FiberPool::Push([=]() mutable { + if (RayCast(&m_Entity).Cast()) + { + if (m_Entity.IsPed()) + { + auto location = m_Entity.GetPosition(); + location.z -= 1.0f; + + Object::Create("prop_gold_cont_01"_J, location); + } + else + { + Notifications::Show("Custom Weapon", "Entity is not a ped.", NotificationType::Warning); + } + } + }); + } + } + break; + } + case CustomWeapons::DELETE_GUN: + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + if (RayCast(&m_Entity).Cast()) + { + if (m_Entity.IsPed() && m_Entity.IsPlayer()) + Notifications::Show("Custom Weapon", "Player entity cannot be deleted.", NotificationType::Warning); + else + { + auto location = m_Entity.GetPosition(); + auto distance = Self::GetPed().GetPosition().GetDistance(location); + + if (distance > 500) + Notifications::Show("Custom Weapon", "Entity is too far.", NotificationType::Warning); + else + m_Entity.Delete(); + } + } + } + } + break; + } + case CustomWeapons::GRAVITY_GUN: + { + static std::vector entities; + static Vector3 location; + static Vector3 entityPos; + static float distance; + static constexpr double multiplier = 3.0; + static const int scroll = 0; + + auto ApplyVelocity = [](Entity entity) { + if (entity.IsValid()) + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT)) + distance -= 5; + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV)) + distance += 5; + + if (!entity.RequestControl(0)) + return; + + entity.SetCollision(false); + + entityPos = entity.GetPosition(); + + Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2); + float pitch = Math::DegToRad(rot.x); // vertical + // float roll = rot.y; + float yaw = Math::DegToRad(rot.z + 90); // horizontal + + Vector3 velocity; + + velocity.x = location.x + (distance * cos(pitch) * cos(yaw)) - entityPos.x; + velocity.y = location.y + (distance * sin(yaw) * cos(pitch)) - entityPos.y; + velocity.z = location.z + (distance * sin(pitch)) - entityPos.z; + + velocity.x *= (float)multiplier; + velocity.y *= (float)multiplier; + velocity.z *= (float)multiplier; + + entity.SetVelocity(velocity); + entity.SetAlpha(105); + } + }; + + FiberPool::Push([=]() mutable { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + location = Self::GetPed().GetPosition(); + + if (PAD::IS_DISABLED_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + if (RayCast(&m_Entity).Cast()) + { + auto entityHandle = m_Entity.GetHandle(); + + if (m_Entity.IsPed() && m_Entity.IsPlayer()) + { + Notifications::Show("Custom Weapon", "Gravity gun cannot be applied on player entity.", NotificationType::Warning); + } + else + { + const auto tempDistance = m_Entity.GetPosition().GetDistance(location); + + if (entities.size() == 0) + { + distance = tempDistance; + } + + if (tempDistance > 500) + { + Notifications::Show("Custom Weapon", "Entity is too far.", NotificationType::Warning); + } + else + { + if (m_Entity.RequestControl(0) && m_Entity.IsPed() && !PED::IS_PED_RAGDOLL(entityHandle)) + { + TASK::SET_HIGH_FALL_TASK(entityHandle, 0, 0, 0); + } + + entities.push_back(m_Entity); + } + } + } + } + + if (entities.size() > 0) + { + for (const auto& entity : entities) + { + ApplyVelocity(entity); + } + } + } + else if (entities.size() > 0) + { + for (Entity& entity : entities) + { + if (entity.RequestControl(0)) + { + if (_GravityGunLaunchOnRelease.GetState()) + { + distance += 100; + ApplyVelocity(entity); + } + + entity.SetCollision(true); + entity.ResetAlpha(); + } + } + + entities.clear(); + } + }); + break; + } + case CustomWeapons::STEAL_VEHICLE_GUN: + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + if (RayCast(&m_Entity).Cast()) + { + auto entityHandle = m_Entity.GetHandle(); + + if (m_Entity.IsVehicle()) + { + for (size_t i = 0; i < 8 && !m_Entity.As().IsSeatFree(-1); i++) + { + const auto ped = VEHICLE::GET_PED_IN_VEHICLE_SEAT(entityHandle, -1, 0); + + if (PED::IS_PED_A_PLAYER(ped)) + return + + TASK::CLEAR_PED_TASKS_IMMEDIATELY(ped); + } + + Self::GetPed().SetInVehicle(m_Entity.As(), -1); + } + else + { + Notifications::Show("Custom Weapon", "Invalid vehicle.", NotificationType::Warning); + } + } + } + } + break; + } + case CustomWeapons::REPAIR_GUN: + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + if (RayCast(&m_Entity).Cast()) + { + if (m_Entity.IsVehicle()) + { + m_Entity.As().Fix(); + } + else + { + Notifications::Show("Custom Weapon", "Invalid vehicle.", NotificationType::Warning); + } + } + } + } + break; + } + case CustomWeapons::VEHICLE_GUN: + { + static TIMER vehicleGunTimer; + + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) && vehicleGunTimer.HasTimePassed(100, true)) + { + if (!_VehicleGunModel.GetString().length()) + { + Notifications::Show("Custom Weapon", "No vehicle model name provided.", NotificationType::Error); + return; + } + + auto modelHash = Joaat(_VehicleGunModel.GetString()); + if (!STREAMING::IS_MODEL_IN_CDIMAGE(modelHash)) + { + Notifications::Show("Custom Weapon", "Invalid vehicle model name provided.", NotificationType::Error); + } + else + { + Vector3 location = CAM::GET_GAMEPLAY_CAM_COORD(); + + FiberPool::Push([location, modelHash]() { + constexpr int rotation_order = 2; + auto rot = CAM::GET_GAMEPLAY_CAM_ROT(rotation_order); + + float pitch = Math::DegToRad(rot.x); // vertical + //float roll = rot.y; + float yaw = Math::DegToRad(rot.z); // horizontal + + Vector3 forward{-sin(yaw) * cos(pitch), cos(yaw) * cos(pitch), sin(pitch)}; + Vector3 spawnLoc = location; + + spawnLoc.x += forward.x * 10.f; + spawnLoc.y += forward.y * 10.f; + spawnLoc.z += forward.z * 10.f; + + auto veh = Vehicle::Create(modelHash, spawnLoc, Self::GetPed().GetHeading(), false); + + Vector3 velocity{forward.x * 150.f, forward.y * 150.f, forward.z * 150.f}; + + veh.SetRotation(rot, rotation_order); + veh.SetVelocity(velocity); + + auto vehHandle = veh.GetHandle(); + ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&vehHandle); + }); + } + + vehicleGunTimer.Reset(true); + } + } + break; + } + case CustomWeapons::TELEPORT_GUN: + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + Vector3 coords; + + if (RayCast(&m_Entity, &coords).Cast()) + { + if (m_Entity.IsVehicle()) + { + Self::GetPed().SetInVehicle(m_Entity.As(), -2); + } + else + { + if (Self::GetVehicle()) + TASK::CLEAR_PED_TASKS_IMMEDIATELY(Self::GetPed().GetHandle()); + + Self::GetPed().TeleportTo(coords); + } + } + } + } + break; + } + case CustomWeapons::PAINT_GUN: + { + static Color paintGunColor; + Color color; + + if (_PaintGunRainbowColorEnabled.GetState()) + { + RainbowColor(paintGunColor, _PaintGunRainbowColorSpeed.GetState(), static_cast(_PaintGunRainbowColorStyle.GetState())); + color = Color(paintGunColor.r / 255.f, paintGunColor.g / 255.f, paintGunColor.b / 255.f, paintGunColor.a / 255.f); + } + else + { + color = Color(_PaintGunColor.GetState()); + } + + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + Vector3 coords; + + if (RayCast(&coords).Cast()) + { + GRAPHICS::ADD_DECAL((int)DecalTypes::splatters_paint, + coords.x, + coords.y, + coords.z, + 0, //true + 0, //true + -1, //true + 0, + 1.f, + 0.f, // always 0 + 0.5f, //size x + 0.4f, //size y + color.r, + color.g, + color.b, + color.a, + -1, + true, + false, + false); + } + } + } + break; + } + default: break; + } + } +} \ No newline at end of file diff --git a/src/game/features/self/CustomWeapon.hpp b/src/game/features/self/CustomWeapon.hpp new file mode 100644 index 0000000..027c8b5 --- /dev/null +++ b/src/game/features/self/CustomWeapon.hpp @@ -0,0 +1,72 @@ +#pragma once +#include "core/commands/BoolCommand.hpp" +#include "core/commands/ColorCommand.hpp" +#include "core/commands/IntCommand.hpp" +#include "core/commands/ListCommand.hpp" +#include "core/commands/LoopedCommand.hpp" +#include "core/commands/StringCommand.hpp" +#include "core/util/Math.hpp" +#include "core/util/RainbowColor.hpp" +#include "game/gta/Entity.hpp" +#include "game/gta/Natives.hpp" +#include "types/pad/ControllerInputs.hpp" + +namespace YimMenu::Features +{ + enum class CustomWeapons + { + CAGE_GUN, + DELETE_GUN, + GRAVITY_GUN, + STEAL_VEHICLE_GUN, + REPAIR_GUN, + VEHICLE_GUN, + TELEPORT_GUN, + PAINT_GUN + }; + + static const ControllerInputs attackControls[] = { + ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + ControllerInputs::INPUT_ATTACK, + ControllerInputs::INPUT_ATTACK2, + ControllerInputs::INPUT_VEH_ATTACK, + ControllerInputs::INPUT_VEH_ATTACK2, + ControllerInputs::INPUT_VEH_PASSENGER_ATTACK, + ControllerInputs::INPUT_VEH_FLY_ATTACK, + ControllerInputs::INPUT_VEH_FLY_ATTACK2, + }; + + static std::vector> g_CustomWeaponTypes = { + {static_cast(CustomWeapons::CAGE_GUN), "Cage Gun"}, + {static_cast(CustomWeapons::DELETE_GUN), "Delete Gun"}, + {static_cast(CustomWeapons::GRAVITY_GUN), "Gravity Gun"}, + {static_cast(CustomWeapons::STEAL_VEHICLE_GUN), "Steal Vehicle Gun"}, + {static_cast(CustomWeapons::REPAIR_GUN), "Repair Gun"}, + {static_cast(CustomWeapons::VEHICLE_GUN), "Vehicle Gun"}, + {static_cast(CustomWeapons::TELEPORT_GUN), "Teleport Gun"}, + {static_cast(CustomWeapons::PAINT_GUN), "Paint Gun"}, + }; + static ListCommand _CustomWeaponType{"customweapontype", "Weapon Type", "The type of custom weapon to use", g_CustomWeaponTypes, static_cast(CustomWeapons::CAGE_GUN)}; + + static std::vector> g_PaintGunRainbowColorStyles = { + {static_cast(RainbowColorStyle::Fade), "Fade"}, + {static_cast(RainbowColorStyle::Spasm), "Spasm"} + }; + static ListCommand _PaintGunRainbowColorStyle{"paintgunrainbowcolorstyle", "Rainbow Color Style", "Style of rainbow color for paint gun", g_PaintGunRainbowColorStyles, static_cast(RainbowColorStyle::Fade)}; + + class CustomWeapon : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override; + }; + + static CustomWeapon _CustomWeapon{"customweapon", "Custom Weapon", "Modifies weapon ability"}; + static BoolCommand _CustomWeaponEnabledOnWeaponOut{"customweaponenabledonweaponout", "Enable Only if Weapon is Out", "Enables custom weapon only when weapon is out", true}; + static BoolCommand _GravityGunLaunchOnRelease{"gravitygunlaunchonrelease", "Launch Entity on Release", "Launches entity when released", false}; + static StringCommand _VehicleGunModel{"vehiclegunmodel", "Vehicle Model", "Model of the vehicle"}; + static ColorCommand _PaintGunColor{"paintguncolor", "Paint Gun Color", "Color of the paint gun"}; + static BoolCommand _PaintGunRainbowColorEnabled{"paintgunrainbowcolorenabled", "Rainbow Color", "Enables rainbow color for paint gun", false}; + static IntCommand _PaintGunRainbowColorSpeed{"paintgunrainbowcolorspeed", "Rainbow Color Speed", "Speed of rainbow color for paint gun", 1, 10, 1}; +} \ No newline at end of file diff --git a/src/game/frontend/items/ConditionalItem.cpp b/src/game/frontend/items/ConditionalItem.cpp index 2f5d37b..890f77e 100644 --- a/src/game/frontend/items/ConditionalItem.cpp +++ b/src/game/frontend/items/ConditionalItem.cpp @@ -7,25 +7,34 @@ namespace YimMenu { ConditionalItem::ConditionalItem(joaat_t bool_cmd_id, std::shared_ptr to_draw, bool negate) : - m_Condition(Commands::GetCommand(bool_cmd_id)), - m_Item(to_draw), - m_Negate(negate) + m_Condition(Commands::GetCommand(bool_cmd_id)), + m_ConditionFn(nullptr), + m_Item(to_draw), + m_Negate(negate) + { + } + + ConditionalItem::ConditionalItem(std::function condition_fn, std::shared_ptr to_draw, bool negate) : + m_Condition(nullptr), + m_ConditionFn(condition_fn), + m_Item(to_draw), + m_Negate(negate) { } void ConditionalItem::Draw() { - if (!m_Condition) - { - return; - } - - if (m_Condition->GetState() ^ m_Negate) + if (CanDraw()) m_Item->Draw(); } bool ConditionalItem::CanDraw() { - return m_Condition->GetState() ^ m_Negate; + if (m_Condition) + return m_Condition->GetState() ^ m_Negate; + else if (m_ConditionFn) + return m_ConditionFn() ^ m_Negate; + + return false; } } \ No newline at end of file diff --git a/src/game/frontend/items/Items.hpp b/src/game/frontend/items/Items.hpp index 07ebebd..68c2288 100644 --- a/src/game/frontend/items/Items.hpp +++ b/src/game/frontend/items/Items.hpp @@ -116,11 +116,13 @@ namespace YimMenu { public: explicit ConditionalItem(joaat_t bool_cmd_id, std::shared_ptr to_draw, bool negate = false); + explicit ConditionalItem(std::function condition_fn, std::shared_ptr to_draw, bool negate = false); void Draw() override; bool CanDraw() override; private: BoolCommand* m_Condition; + std::function m_ConditionFn; std::shared_ptr m_Item; bool m_Negate; }; @@ -206,6 +208,22 @@ namespace YimMenu std::vector> m_Items; }; + class TabBarItem : public UIItem + { + public: + explicit TabBarItem(const std::string& id); + void Draw() override; + + void AddItem(std::shared_ptr&& tab) + { + m_Tabs.push_back(std::move(tab)); + } + + private: + std::string m_Id; + std::vector> m_Tabs; + }; + class CollapsingHeaderItem : public UIItem { public: diff --git a/src/game/frontend/items/TabBarItem.cpp b/src/game/frontend/items/TabBarItem.cpp new file mode 100644 index 0000000..ef17501 --- /dev/null +++ b/src/game/frontend/items/TabBarItem.cpp @@ -0,0 +1,22 @@ +#include "Items.hpp" + +namespace YimMenu +{ + TabBarItem::TabBarItem(const std::string& id) : + m_Id(id) + { + } + + void TabBarItem::Draw() + { + if (ImGui::BeginTabBar(m_Id.c_str())) + { + for (const auto& tab : m_Tabs) + { + if (tab->CanDraw()) + tab->Draw(); + } + ImGui::EndTabBar(); + } + } +} \ No newline at end of file diff --git a/src/game/frontend/submenus/Debug/Scripts.cpp b/src/game/frontend/submenus/Debug/Scripts.cpp index f9d63eb..3d2292f 100644 --- a/src/game/frontend/submenus/Debug/Scripts.cpp +++ b/src/game/frontend/submenus/Debug/Scripts.cpp @@ -129,6 +129,7 @@ namespace YimMenu::Submenus { auto menu = std::make_unique("Scripts"); + auto tabBar = std::make_unique("Scripts"); auto threads = std::make_unique("Threads"); auto script = std::make_unique("Start Script"); @@ -403,14 +404,11 @@ namespace YimMenu::Submenus } })); - menu->AddItem(std::make_shared([] { - ImGui::BeginTabBar("Scripts"); - })); - menu->AddItem(std::move(threads)); - menu->AddItem(std::move(script)); - menu->AddItem(std::make_shared([] { - ImGui::EndTabBar(); - })); + tabBar->AddItem(std::move(threads)); + tabBar->AddItem(std::move(script)); + + menu->AddItem(std::move(tabBar)); + return menu; } } \ No newline at end of file diff --git a/src/game/frontend/submenus/Recovery/Heist/ApartmentHeist.hpp b/src/game/frontend/submenus/Recovery/Heist/ApartmentHeist.hpp index 7de2104..0ad1b65 100644 --- a/src/game/frontend/submenus/Recovery/Heist/ApartmentHeist.hpp +++ b/src/game/frontend/submenus/Recovery/Heist/ApartmentHeist.hpp @@ -1,3 +1,4 @@ +#pragma once #include "game/frontend/submenus/Recovery/HeistModifier.hpp" namespace YimMenu::Submenus diff --git a/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.cpp b/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.cpp index a4050e1..951ed9b 100644 --- a/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.cpp +++ b/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.cpp @@ -8,7 +8,7 @@ namespace YimMenu::Submenus auto cuts = std::make_shared("Heist Cuts", 2); auto setups = std::make_shared("Heist Setups"); - auto loots = std::make_shared("Loots"); + auto loots = std::make_shared("Loots", 2); auto misc = std::make_shared("Misc", 1); cuts->AddItem(std::make_shared("cayopericoheistcut1"_J)); @@ -24,14 +24,8 @@ namespace YimMenu::Submenus setups->AddItem(std::make_shared("cayopericoheistsetup"_J)); loots->AddItem(std::make_shared("cayopericoheistprimarytargetvalue"_J)); - loots->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); - loots->AddItem(std::make_shared("cayopericoheistsetprimarytargetvalue"_J, "Set##primarytargetvalue")); loots->AddItem(std::make_shared("cayopericoheistsecondarytakevalue"_J)); - loots->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); + loots->AddItem(std::make_shared("cayopericoheistsetprimarytargetvalue"_J, "Set##primarytargetvalue")); loots->AddItem(std::make_shared("cayopericoheistsetsecondarytakevalue"_J, "Set##secondarytakevalue")); misc->AddItem(std::make_shared("cayopericoheistskiphacking"_J)); diff --git a/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.hpp b/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.hpp index 59dddfa..1917423 100644 --- a/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.hpp +++ b/src/game/frontend/submenus/Recovery/Heist/CayoPericoHeist.hpp @@ -1,3 +1,4 @@ +#pragma once #include "game/frontend/submenus/Recovery/HeistModifier.hpp" namespace YimMenu::Submenus diff --git a/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.cpp b/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.cpp index a7b9463..484c2aa 100644 --- a/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.cpp +++ b/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.cpp @@ -7,9 +7,8 @@ namespace YimMenu::Submenus auto tab = std::make_shared("Diamond Casino Heist"); auto cuts = std::make_shared("Heist Cuts", 2); - auto setups1 = std::make_shared("Heist Setups"); - auto setups2 = std::make_shared(""); - auto loots = std::make_shared("Loots"); + auto setups = std::make_shared("Heist Setups"); + auto loots = std::make_shared("Loots", 2); auto misc = std::make_shared("Misc", 1); cuts->AddItem(std::make_shared("diamondcasinoheistcut1"_J)); @@ -19,31 +18,22 @@ namespace YimMenu::Submenus cuts->AddItem(std::make_shared("diamondcasinoheistforceready"_J)); cuts->AddItem(std::make_shared("diamondcasinoheistsetcuts"_J)); - setups1->AddItem(std::make_shared("diamondcasinoheistdifficulty"_J)); - setups1->AddItem(std::make_shared("diamondcasinoheistprimarytarget"_J)); - setups1->AddItem(std::make_shared("diamondcasinoheistapproach"_J)); - setups1->AddItem(std::make_shared("diamondcasinoheistgunman"_J)); - setups1->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); - setups1->AddItem(std::make_shared("diamondcasinoheistweapon"_J)); - setups2->AddItem(std::make_shared("diamondcasinoheistdriver"_J)); - setups2->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); - setups2->AddItem(std::make_shared("diamondcasinoheistvehicle"_J)); - setups2->AddItem(std::make_shared("diamondcasinoheisthacker"_J)); - setups2->AddItem(std::make_shared("diamondcasinoheistsetup"_J)); + auto gunmanAndDriver = std::make_shared("", 2); + gunmanAndDriver->AddItem(std::make_shared("diamondcasinoheistgunman"_J)); + gunmanAndDriver->AddItem(std::make_shared("diamondcasinoheistdriver"_J)); + gunmanAndDriver->AddItem(std::make_shared("diamondcasinoheistweapon"_J)); + gunmanAndDriver->AddItem(std::make_shared("diamondcasinoheistvehicle"_J)); + + setups->AddItem(std::make_shared("diamondcasinoheistdifficulty"_J)); + setups->AddItem(std::make_shared("diamondcasinoheistprimarytarget"_J)); + setups->AddItem(std::make_shared("diamondcasinoheistapproach"_J)); + setups->AddItem(std::move(gunmanAndDriver)); + setups->AddItem(std::make_shared("diamondcasinoheisthacker"_J)); + setups->AddItem(std::make_shared("diamondcasinoheistsetup"_J)); loots->AddItem(std::make_shared("diamondcasinoheistpotentialtake"_J)); - loots->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); - loots->AddItem(std::make_shared("diamondcasinoheistsetpotentialtake"_J, "Set##potentialtake")); loots->AddItem(std::make_shared("diamondcasinoheistactualtake"_J)); - loots->AddItem(std::make_shared([] { - ImGui::SameLine(); - })); + loots->AddItem(std::make_shared("diamondcasinoheistsetpotentialtake"_J, "Set##potentialtake")); loots->AddItem(std::make_shared("diamondcasinoheistsetactualtake"_J, "Set##actualtake")); misc->AddItem(std::make_shared("diamondcasinoheistskiphacking"_J)); @@ -51,8 +41,7 @@ namespace YimMenu::Submenus misc->AddItem(std::make_shared("diamondcasinoheistinstantfinish"_J)); tab->AddItem(cuts); - tab->AddItem(setups1); - tab->AddItem(setups2); + tab->AddItem(setups); tab->AddItem(loots); tab->AddItem(misc); diff --git a/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.hpp b/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.hpp index 7394e33..d28695d 100644 --- a/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.hpp +++ b/src/game/frontend/submenus/Recovery/Heist/DiamondCasinoHeist.hpp @@ -1,3 +1,4 @@ +#pragma once #include "game/frontend/submenus/Recovery/HeistModifier.hpp" namespace YimMenu::Submenus diff --git a/src/game/frontend/submenus/Recovery/Heist/DoomsdayHeist.hpp b/src/game/frontend/submenus/Recovery/Heist/DoomsdayHeist.hpp index 078d71e..77fca1a 100644 --- a/src/game/frontend/submenus/Recovery/Heist/DoomsdayHeist.hpp +++ b/src/game/frontend/submenus/Recovery/Heist/DoomsdayHeist.hpp @@ -1,3 +1,4 @@ +#pragma once #include "game/frontend/submenus/Recovery/HeistModifier.hpp" namespace YimMenu::Submenus diff --git a/src/game/frontend/submenus/Recovery/HeistModifier.cpp b/src/game/frontend/submenus/Recovery/HeistModifier.cpp index 5b7c01a..08887fc 100644 --- a/src/game/frontend/submenus/Recovery/HeistModifier.cpp +++ b/src/game/frontend/submenus/Recovery/HeistModifier.cpp @@ -8,18 +8,15 @@ namespace YimMenu::Submenus { std::shared_ptr BuildHeistModifierMenu() { - auto menu = std::make_shared("Heists"); + auto menu = std::make_shared("Heists"); + auto heistTabBar = std::make_shared("Heist Modifier"); - menu->AddItem(std::make_shared([] { - ImGui::BeginTabBar("Heist Modifier"); - })); - menu->AddItem(RenderApartmentHeistMenu()); - menu->AddItem(RenderDiamondCasinoHeistMenu()); - menu->AddItem(RenderCayoPericoHeistMenu()); - menu->AddItem(RenderDoomsdayHeistMenu()); - menu->AddItem(std::make_shared([] { - ImGui::EndTabBar(); - })); + heistTabBar->AddItem(RenderApartmentHeistMenu()); + heistTabBar->AddItem(RenderDiamondCasinoHeistMenu()); + heistTabBar->AddItem(RenderCayoPericoHeistMenu()); + heistTabBar->AddItem(RenderDoomsdayHeistMenu()); + + menu->AddItem(std::move(heistTabBar)); return menu; } diff --git a/src/game/frontend/submenus/Self/Weapons.cpp b/src/game/frontend/submenus/Self/Weapons.cpp index f42ec71..4f5e00c 100644 --- a/src/game/frontend/submenus/Self/Weapons.cpp +++ b/src/game/frontend/submenus/Self/Weapons.cpp @@ -7,6 +7,8 @@ #include "game/gta/Scripts.hpp" #include "game/gta/ScriptFunction.hpp" #include "types/script/scrThread.hpp" +#include "core/commands/Commands.hpp" +#include "game/features/self/CustomWeapon.hpp" namespace YimMenu::Submenus { @@ -163,11 +165,52 @@ namespace YimMenu::Submenus } } + static std::shared_ptr RenderCustomWeaponsMenu() + { + auto customWeaponsGroup = std::make_shared("Custom Weapons"); + + auto cutomWeaponTypes = std::make_shared("", 1); + auto customWeapons = std::make_shared(""); + auto paintGunGroup = std::make_shared(""); + + auto cmd = Commands::GetCommand("customweapontype"_J); + + auto isGravityGunEnabled = [cmd] { + return static_cast(cmd->GetState()) == Features::CustomWeapons::GRAVITY_GUN; + }; + + auto isVehicleGunEnabled = [cmd] { + return static_cast(cmd->GetState()) == Features::CustomWeapons::VEHICLE_GUN; + }; + + auto isPaintGunEnabled = [cmd] { + return static_cast(cmd->GetState()) == Features::CustomWeapons::PAINT_GUN; + }; + + cutomWeaponTypes->AddItem(std::make_shared("customweapontype"_J)); + cutomWeaponTypes->AddItem(std::make_shared(isGravityGunEnabled, std::make_shared("gravitygunlaunchonrelease"_J))); + cutomWeaponTypes->AddItem(std::make_shared(isVehicleGunEnabled, std::make_shared("vehiclegunmodel"_J))); + cutomWeaponTypes->AddItem(std::make_shared(isPaintGunEnabled, std::make_shared("paintgunrainbowcolorenabled"_J, std::make_shared("paintguncolor"_J), true))); + + paintGunGroup->AddItem(std::make_shared("paintgunrainbowcolorenabled"_J)); + paintGunGroup->AddItem(std::make_shared("paintgunrainbowcolorenabled"_J, std::make_shared("paintgunrainbowcolorstyle"_J))); + paintGunGroup->AddItem(std::make_shared("paintgunrainbowcolorenabled"_J, std::make_shared("paintgunrainbowcolorspeed"_J))); + + customWeapons->AddItem(std::make_shared("customweaponenabledonweaponout"_J)); + customWeapons->AddItem(std::move(cutomWeaponTypes)); + customWeapons->AddItem(std::make_shared(isPaintGunEnabled, std::move(paintGunGroup))); + + customWeaponsGroup->AddItem(std::make_shared("customweapon"_J)); + customWeaponsGroup->AddItem(std::make_shared("customweapon"_J, std::move(customWeapons))); + + return customWeaponsGroup; + } + std::shared_ptr BuildWeaponsMenu() { auto weapons = std::make_shared("Weapons"); - auto weaponsGlobalsGroup = std::make_shared("Globals"); + auto weaponsGlobalsGroup = std::make_shared("Globals", 12); auto weaponsToolsGroup = std::make_shared("Tools", 1); auto weaponsAmmuNationGroup = std::make_shared("Ammu-Nation"); auto weaponsAimbotGroup = std::make_shared("Aimbot", 1); @@ -202,6 +245,7 @@ namespace YimMenu::Submenus weapons->AddItem(weaponsToolsGroup); weapons->AddItem(weaponsAmmuNationGroup); weapons->AddItem(weaponsAimbotGroup); + weapons->AddItem(RenderCustomWeaponsMenu()); return weapons; } } \ No newline at end of file diff --git a/src/game/frontend/submenus/Vehicle/SpawnVehicle.cpp b/src/game/frontend/submenus/Vehicle/SpawnVehicle.cpp index 50b53f5..32a2f47 100644 --- a/src/game/frontend/submenus/Vehicle/SpawnVehicle.cpp +++ b/src/game/frontend/submenus/Vehicle/SpawnVehicle.cpp @@ -239,14 +239,12 @@ namespace YimMenu::Submenus { auto menu = std::make_shared("Spawn"); - menu->AddItem(std::make_shared([] { - ImGui::BeginTabBar("Spawn"); - })); - menu->AddItem(RenderSpawnNewVehicle()); - menu->AddItem(RenderSpawnPersonalVehicle()); - menu->AddItem(std::make_shared([] { - ImGui::EndTabBar(); - })); + auto tabBar = std::make_shared("Spawn"); + + tabBar->AddItem(RenderSpawnNewVehicle()); + tabBar->AddItem(RenderSpawnPersonalVehicle()); + + menu->AddItem(std::move(tabBar)); return menu; } diff --git a/src/game/gta/RayCast.cpp b/src/game/gta/RayCast.cpp new file mode 100644 index 0000000..656c3e0 --- /dev/null +++ b/src/game/gta/RayCast.cpp @@ -0,0 +1,66 @@ +#include "RayCast.hpp" +#include "game/gta/Natives.hpp" +#include "core/util/Math.hpp" + +namespace YimMenu +{ + RayCast::RayCast(Entity* entity, Vector3* coords) : + m_Entity(entity), + m_Coords(coords) + { + } + + RayCast::RayCast(Entity* entity) : + m_Entity(entity), + m_Coords() + { + } + + RayCast::RayCast(Vector3* coords) : + m_Entity(nullptr), + m_Coords(coords) + { + } + + bool RayCast::Cast() + { + Vector3 camCoords = CAM::GET_GAMEPLAY_CAM_COORD(); + Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2); + Vector3 dir = Math::RotationToDirection(rot); + Vector3 farCoords; + + farCoords.x = camCoords.x + dir.x * 1000; + farCoords.y = camCoords.y + dir.y * 1000; + farCoords.z = camCoords.z + dir.z * 1000; + + int shapeTestHandle = SHAPETEST::START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE(camCoords.x, + camCoords.y, + camCoords.z, + farCoords.x, + farCoords.y, + farCoords.z, + -1, + 0, + 7); + + BOOL hit; + Vector3 endCoords; + Vector3 surfaceNormal; + int entityHit; + + int testResult = SHAPETEST::GET_SHAPE_TEST_RESULT(shapeTestHandle, &hit, &endCoords, &surfaceNormal, &entityHit); + + if (testResult == 2 && hit == TRUE) + { + if (m_Entity) + *m_Entity = Entity(entityHit); + + if (m_Coords) + *m_Coords = endCoords; + + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/src/game/gta/RayCast.hpp b/src/game/gta/RayCast.hpp new file mode 100644 index 0000000..9625552 --- /dev/null +++ b/src/game/gta/RayCast.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "Entity.hpp" +#include "types/script/types.hpp" + +namespace YimMenu +{ + class RayCast + { + public: + RayCast(Entity* entity, Vector3* coords); + RayCast(Entity* entity); + RayCast(Vector3* coords); + bool Cast(); + + private: + Entity* m_Entity; + Vector3* m_Coords; + }; +} \ No newline at end of file diff --git a/src/game/gta/Vehicle.cpp b/src/game/gta/Vehicle.cpp index 968a7bb..2004ab6 100644 --- a/src/game/gta/Vehicle.cpp +++ b/src/game/gta/Vehicle.cpp @@ -7,7 +7,7 @@ namespace YimMenu { - Vehicle Vehicle::Create(std::uint32_t model, rage::fvector3 coords, float heading) + Vehicle Vehicle::Create(std::uint32_t model, rage::fvector3 coords, float heading, bool setOnGroundProperly) { ENTITY_ASSERT_SCRIPT_CONTEXT(); if (!STREAMING::IS_MODEL_IN_CDIMAGE(model)) @@ -46,7 +46,8 @@ namespace YimMenu DECORATOR::DECOR_SET_INT(veh.GetHandle(), "MPBitset", 0); NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(NETWORK::VEH_TO_NET(veh.GetHandle()), true); - VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(veh.GetHandle(), 0); + if (setOnGroundProperly) + VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(veh.GetHandle(), 0); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(model); return veh; diff --git a/src/game/gta/Vehicle.hpp b/src/game/gta/Vehicle.hpp index cc1b043..e43a0d9 100644 --- a/src/game/gta/Vehicle.hpp +++ b/src/game/gta/Vehicle.hpp @@ -10,7 +10,7 @@ namespace YimMenu public: using Entity::Entity; - static Vehicle Create(std::uint32_t model, rage::fvector3 coords, float heading = 0.0f); + static Vehicle Create(std::uint32_t model, rage::fvector3 coords, float heading = 0.0f, bool setOnGroundProperly = true); // health void Fix(); diff --git a/src/types/entity/DecalTypes.hpp b/src/types/entity/DecalTypes.hpp new file mode 100644 index 0000000..574a250 --- /dev/null +++ b/src/types/entity/DecalTypes.hpp @@ -0,0 +1,57 @@ +#pragma once + +enum class DecalTypes +{ + splatters_blood = 1010, + splatters_blood_dir = 1015, + splatters_blood_mist = 1017, + splatters_mud = 1020, + splatters_paint = 1030, + splatters_water = 1040, + splatters_water_hydrant = 1050, + splatters_blood2 = 1110, + weapImpact_metal = 4010, + weapImpact_concrete = 4020, + weapImpact_mattress = 4030, + weapImpact_mud = 4032, + weapImpact_wood = 4050, + weapImpact_sand = 4053, + weapImpact_cardboard = 4040, + weapImpact_melee_glass = 4100, + weapImpact_glass_blood = 4102, + weapImpact_glass_blood2 = 4104, + weapImpact_shotgun_paper = 4200, + weapImpact_shotgun_mattress, + weapImpact_shotgun_metal, + weapImpact_shotgun_wood, + weapImpact_shotgun_dirt, + weapImpact_shotgun_tvscreen, + weapImpact_shotgun_tvscreen2, + weapImpact_shotgun_tvscreen3, + weapImpact_melee_concrete = 4310, + weapImpact_melee_wood = 4312, + weapImpact_melee_metal = 4314, + burn1 = 4421, + burn2, + burn3, + burn4, + burn5, + bang_concrete_bang = 5000, + bang_concrete_bang2, + bang_bullet_bang, + bang_bullet_bang2 = 5004, + bang_glass = 5031, + bang_glass2, + solidPool_water = 9000, + solidPool_blood, + solidPool_oil, + solidPool_petrol, + solidPool_mud, + porousPool_water, + porousPool_blood, + porousPool_oil, + porousPool_petrol, + porousPool_mud, + porousPool_water_ped_drip, + liquidTrail_water = 9050 +}; \ No newline at end of file