Skip to content

add heist modifier #181

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

Merged
merged 3 commits into from
Apr 19, 2025
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
6 changes: 6 additions & 0 deletions src/core/commands/ListCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ namespace YimMenu
MarkDirty();
}

void ListCommand::SetList(std::vector<std::pair<int, const char*>> list)
{
m_List = std::move(list);
MarkDirty();
}

std::vector<std::pair<int, const char*>>& ListCommand::GetList()
{
return m_List;
Expand Down
1 change: 1 addition & 0 deletions src/core/commands/ListCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace YimMenu
ListCommand(std::string name, std::string label, std::string description, std::vector<std::pair<int, const char*>> list, int def_val = 0);
int GetState();
void SetState(int state);
void SetList(std::vector<std::pair<int, const char*>> list);
std::vector<std::pair<int, const char*>>& GetList();
};
}
19 changes: 0 additions & 19 deletions src/game/features/recovery/CayoPericoCooldown.cpp

This file was deleted.

47 changes: 0 additions & 47 deletions src/game/features/recovery/CayoPericoSetup.cpp

This file was deleted.

132 changes: 132 additions & 0 deletions src/game/features/recovery/Heist/ApartmentHeist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#include "core/commands/IntCommand.hpp"
#include "core/commands/Command.hpp"
#include "game/gta/Stats.hpp"
#include "game/backend/Players.hpp"
#include "game/gta/ScriptGlobal.hpp"
#include "game/gta/ScriptLocal.hpp"
#include "core/backend/ScriptMgr.hpp"
#include "types/script/globals/GlobalPlayerBD.hpp"

namespace YimMenu::Features
{
namespace ApartmentHeist
{
static IntCommand _ApartmentHeistCut1{"apartmentheistcut1", "Player 1", "Player 1 cut", std::nullopt, std::nullopt, 0};
static IntCommand _ApartmentHeistCut2{"apartmentheistcut2", "Player 2", "Player 2 cut", std::nullopt, std::nullopt, 0};
static IntCommand _ApartmentHeistCut3{"apartmentheistcut3", "Player 3", "Player 3 cut", std::nullopt, std::nullopt, 0};
static IntCommand _ApartmentHeistCut4{"apartmentheistcut4", "Player 4", "Player 4 cut", std::nullopt, std::nullopt, 0};

class SetCuts : public Command
{
using Command::Command;

virtual void OnCall() override
{
auto base1 = ScriptGlobal(1929794).At(1);
auto base2 = ScriptGlobal(1931762).At(3008);

*base1.At(1).As<int*>() = 100 - (_ApartmentHeistCut1.GetState() + _ApartmentHeistCut2.GetState() + _ApartmentHeistCut3.GetState() + _ApartmentHeistCut4.GetState());
*base1.At(2).As<int*>() = _ApartmentHeistCut2.GetState();
*base1.At(3).As<int*>() = _ApartmentHeistCut3.GetState();
*base1.At(4).As<int*>() = _ApartmentHeistCut4.GetState();

ScriptMgr::Yield(500ms);

*base2.At(1).As<int*>() = -1 * (*base1.At(1).As<int*>() + *base1.At(2).As<int*>() + *base1.At(3).As<int*>() + *base1.At(4).As<int*>() - 100);
*base2.At(2).As<int*>() = *base1.At(2).As<int*>();
*base2.At(3).As<int*>() = *base1.At(3).As<int*>();
*base2.At(4).As<int*>() = *base1.At(4).As<int*>();
}
};

class ForceReady : public Command
{
using Command::Command;

virtual void OnCall() override
{
Copy link
Collaborator

@maybegreat48 maybegreat48 Apr 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterate all players and modify this field in GlobalPlayerBD instead. Modifying others' broadcast stuff is generally bad practice, but you should be fine for this one (assuming you are the script host)

if (auto gpbd = GlobalPlayerBD::Get(); gpbd && Scripts::SafeToModifyFreemodeBroadcastGlobals())
{
for (auto& player : Players::GetPlayers())
{
gpbd->Entries[player.second.GetId()].HeistCutSelectionStage = 6;
}
}
}
};

class Setup : public Command
{
using Command::Command;

virtual void OnCall() override
{
Stats::SetInt("MPX_HEIST_PLANNING_STAGE", -1);
}
};

class SkipHacking : public Command
{
using Command::Command;

virtual void OnCall() override
{
*ScriptLocal("fm_mission_controller"_J, 12216).At(24).As<int*>() = 7;
*ScriptLocal("fm_mission_controller"_J, 10213).As<int*>() = *ScriptLocal("fm_mission_controller"_J, 10213).As<int*>() | (1 << 9);
}
};

class SkipDrilling : public Command
{
using Command::Command;

virtual void OnCall() override
{
*ScriptLocal("fm_mission_controller"_J, 10507).At(11).As<float*>() = 100.0f;
}
};

class InstantFinish : public Command
{
using Command::Command;

virtual void OnCall() override
{
Scripts::ForceScriptHost(Scripts::FindScriptThread("fm_mission_controller"_J));
ScriptMgr::Yield(500ms);

*ScriptLocal("fm_mission_controller"_J, 20387).At(1725).At(1).As<int*>() = 80;
*ScriptLocal("fm_mission_controller"_J, 20387).As<int*>() = 12;
*ScriptLocal("fm_mission_controller"_J, 29006).At(1).As<int*>() = 99999;
*ScriptLocal("fm_mission_controller"_J, 32462).At(1).At(68).As<int*>() = 99999;

// TODO: find a way of getting current heist info so that InstantFinishPacific can be implemented here conditionally.
}
};

class InstantFinishPacific : public Command
{
using Command::Command;

virtual void OnCall() override
{
Scripts::ForceScriptHost(Scripts::FindScriptThread("fm_mission_controller"_J));
ScriptMgr::Yield(500ms);

*ScriptLocal("fm_mission_controller"_J, 20387).At(2686).As<int*>() = 1875000;
*ScriptLocal("fm_mission_controller"_J, 20387).At(1062).As<int*>() = 5;
*ScriptLocal("fm_mission_controller"_J, 20387).As<int*>() = 12;
*ScriptLocal("fm_mission_controller"_J, 29006).At(1).As<int*>() = 99999;
*ScriptLocal("fm_mission_controller"_J, 32462).At(1).At(68).As<int*>() = 99999;
}
};

static SetCuts _ApartmentHeistSetCuts{"apartmentheistsetcuts", "Set Cuts", "Sets heist cut"};
static ForceReady _ApartmentHeistForceReady{"apartmentheistforceready", "Force Ready", "Forces all players to be ready"};
static Setup _ApartmentHeistSetup{"apartmentheistsetup", "Setup", "Sets up current apartment heist"};
static SkipHacking _ApartmentHeistSkipHacking{"apartmentheistskiphacking", "Skip Hacking", "Skips hacking process"};
static SkipDrilling _ApartmentHeistSkipDrilling{"apartmentheistskipdrilling", "Skip Drilling", "Skips drilling process"};
static InstantFinish _ApartmentHeistInstantFinish{"apartmentheistinstantfinish", "Instant Finish", "Instantly passes the heist"};
static InstantFinishPacific _ApartmentHeistInstantFinishPacific{"apartmentheistinstantfinishpacific", "Instant Finish (Pacific)", "Instantly passes Pacific Standard Job"};
}
}
Loading