Skip to content

Commit

Permalink
2.0.3 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
GTAMadman committed May 20, 2021
1 parent 5d2d625 commit 15f344d
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 28 deletions.
8 changes: 6 additions & 2 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ void Config::PickupsRandomizer::Read(const std::string& line)
ReadConfigBool("EnableBriefcase", line, briefcase);

ReadConfigBool("MoneyInBriefcase", line, briefcaseMoney);
ReadConfigString("PickupsCustomSeed", line, seed);

if (seed != "")
usingSeed = true;
}
void Config::CutsceneRandomizer::Read(const std::string& line)
{
Expand Down Expand Up @@ -142,7 +146,7 @@ void Config::PagerRandomizer::Read(const std::string& line)
void Config::MissionRandomizer::Read(const std::string& line)
{
ReadConfigBool("MissionRandomizer", line, Enabled);
ReadConfigString("CustomSeed", line, seed);
ReadConfigString("MissionCustomSeed", line, seed);
ReadConfigInt("ForcedMission", line, forcedMission);

if (seed != "")
Expand Down Expand Up @@ -171,7 +175,7 @@ void Config::WriteConfig()
void Config::Initialise()
{
if (!std::filesystem::exists(Functions::GetRainbomizerDir()))
CreateDirectory(Functions::GetRainbomizerDir().c_str(), NULL);
return;

if (!std::filesystem::exists(ConfigName))
WriteConfig();
Expand Down
2 changes: 2 additions & 0 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class Config
bool bribes;
bool briefcase;
bool briefcaseMoney;
std::string seed;
bool usingSeed;
void Read(const std::string& line);
} pickups;

Expand Down
5 changes: 4 additions & 1 deletion src/Credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

std::vector<wchar_t*> lead_developers = { L"GTAMADMAN", L"PARIK" };
std::vector<wchar_t*> contributors = { L"123ROBOT", L"FRYTERP23" };
std::vector<wchar_t*> beta_testers = { L"HUGOONE", L"VODCRACK", L"SPEEDYFOLF" };
std::vector<wchar_t*> beta_testers = { L"HUGOONE", L"SPEEDYFOLF", L"VODCRACK" };

void Credits::PrintCredits(float x, float y, const wchar_t* text, int* position, float offset)
{
Expand All @@ -27,6 +27,9 @@ void Credits::ModifyCredits(float x, float y, wchar_t* text, int* position, floa
PrintGroup(L"CONTRIBUTORS", contributors, position, offset);
PrintGroup(L"BETA TESTERS", beta_testers, position, offset);

PrintCredits(1.7, 1.0, L"ROCKSTAR GAMES", position, offset);

*position += 37.5;
PrintCredits(x, y, text, position, offset);
}
void Credits::Initialise()
Expand Down
16 changes: 11 additions & 5 deletions src/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void Functions::LoadModel(int modelID)
{
if (CStreaming::ms_aInfoForModel[modelID].m_nLoadState != 1)
{
CStreaming::RequestModel(modelID, 1);
CStreaming::RequestModel(modelID, 0);
CStreaming::LoadAllRequestedModels(false);
}
}
Expand All @@ -29,11 +29,10 @@ bool Functions::IsModelLoaded(int modelID)
return true;
return false;
}
void Functions::PlayRandomRadioStation()
void Functions::PlayAudioForCredits()
{
gMusicManager.ChangeMusicMode(2);
gMusicManager.PreloadCutSceneMusic(RandomNumber(0, 7));
gMusicManager.PlayPreloadedCutSceneMusic();
gMusicManager.ChangeMusicMode(0);
gMusicManager.PlayFrontEndTrack(RandomNumber(0, 7), 1);
}
int Functions::GetNumberOfVehiclesLoaded()
{
Expand All @@ -54,6 +53,13 @@ bool Functions::IsRampageRunning()

return false;
}
void Functions::UnfreezePlayer()
{
injector::WriteMemory<int>(0x95CD95, 1);
CCutsceneMgr::DeleteCutsceneData();
FindPlayerPed()->SetObjective(eObjective::OBJECTIVE_NONE);
CPad::GetPad(CWorld::PlayerInFocus)->Clear(true);
}
int Functions::RandomNumber(int min, int max)
{
std::uniform_int_distribution random(min, max);
Expand Down
5 changes: 4 additions & 1 deletion src/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "CGame.h"
#include "cMusicManager.h"
#include "CCutsceneMgr.h"
#include "eObjective.h"
#include "CWorld.h"
#include <ctime>
#include <random>

Expand All @@ -25,7 +27,8 @@ class Functions
static int GetNumberOfVehiclesLoaded();
static int GetRandomLoadedVehicle();
static bool IsRampageRunning();
static void PlayRandomRadioStation();
static void PlayAudioForCredits();
static void UnfreezePlayer();
struct CText
{
char* GetText(const char* key);
Expand Down
34 changes: 18 additions & 16 deletions src/Missions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ void Missions::HandleEndThreadOpcode(CRunningScript* thread, short opcode)
if (mRandomizedMission == 19 && mOriginalMission != 19)
{
GetGlobalVariable(245) = 1;
RemoveBridgeObstacles();
replacedByFirstMission = false;
}

Expand Down Expand Up @@ -425,16 +426,6 @@ void Missions::SaveMissionData(uint8_t* data, uint32_t& outSize)
outSize += sizeof(SaveStructure);
}

void __fastcall Missions::FixWalkingAfterChaperone(CPed* ped, void* edx, eObjective obj, float x, int a4, int a5)
{
plugin::CallMethod<0x4D8A90>(ped, obj, x, a4, a5);

if (ped == FindPlayerPed() && x == 1436.25 &&
CTheScripts::pActiveScripts->m_szName == std::string("frank1"))
{
FindPlayerPed()->SetObjective(eObjective::OBJECTIVE_NONE);
}
}
void __fastcall Missions::FixRemovingExchangeMoney(CRunningScript* script, void* edx, int* arg0, short count)
{
script->CollectParameters(arg0, count);
Expand Down Expand Up @@ -469,10 +460,7 @@ void __fastcall Missions::FixGiveMeLibertyMovement(CRunningScript* script, void*
if (mRandomizedMission == 19 && mOriginalMission != 19 &&
script->m_szName == std::string("eight") && movementSetting == 1)
{
injector::WriteMemory<int>(0x95CD95, 1);
CCutsceneMgr::DeleteCutsceneData();
FindPlayerPed()->SetObjective(eObjective::OBJECTIVE_NONE);
CPad::GetPad(CWorld::PlayerInFocus)->Clear(true);
UnfreezePlayer();
}
}
void Missions::BlockExtraText(wchar_t* message, int time, short flag)
Expand Down Expand Up @@ -505,7 +493,7 @@ void __fastcall Missions::ShouldRestartCritical(CPlayerInfo* player)
void Missions::FixEndOfMissions()
{
if (mOriginalMission == 79)
PlayRandomRadioStation();
PlayAudioForCredits();

if (mRandomizedMission == 79)
{
Expand All @@ -519,6 +507,12 @@ void Missions::FixEndOfMissions()

if (mRandomizedMission == 19)
OpenPortlandSafehouseDoor();

if (mRandomizedMission == 35)
{
UnfreezePlayer();
FindPlayerPed()->SetInitialState();
}
}
void __fastcall Missions::RemoveCarCubes(CPathFind* path, void* edx, float x1, float y1,
float z1, float x2, float y2, float z2, char a3)
Expand Down Expand Up @@ -604,6 +598,13 @@ bool Missions::ShouldBuildingBeReplaced(int origModel, int newModel)

return false;
}
void Missions::RemoveBridgeObstacles()
{
if (GetGlobalVariable(1118))
plugin::Command<eScriptCommands::COMMAND_DELETE_OBJECT>(GetGlobalVariable(1118));
if (GetGlobalVariable(1119))
plugin::Command<eScriptCommands::COMMAND_DELETE_OBJECT>(GetGlobalVariable(1119));
}
void Missions::StoreGangThreatStates()
{
gang_threats.mafia = CPedType::ms_apPedType[7]->m_Threat.bPlayer1;
Expand Down Expand Up @@ -695,13 +696,13 @@ void Missions::Initialise()
plugin::patch::RedirectCall(0x44FD27, UnlockBridges);
plugin::patch::RedirectCall(0x453E80, UnlockBridges);
plugin::patch::RedirectCall(0x444F02, RemoveObjects);
plugin::patch::RedirectCall(0x440423, RemoveObjects);
plugin::patch::RedirectCall(0x4A297B, RemoveObjects);
plugin::patch::RedirectCall(0x47899C, RemoveObjects);
plugin::patch::RedirectCall(0x4787FE, RemoveObjects);
plugin::patch::RedirectCall(0x48C9CD, UnlockShoresideBridge);

plugin::patch::RedirectCall(0x44265A, RemoveCarCubes);
plugin::patch::RedirectCall(0x44327A, FixWalkingAfterChaperone);
plugin::patch::RedirectCall(0x43DF22, FixRemovingExchangeMoney);
plugin::patch::RedirectCall(0x447FBD, FixSAMLastMissionName);
plugin::patch::RedirectCall(0x441152, FixGiveMeLibertyMovement);
Expand All @@ -715,6 +716,7 @@ void Missions::Initialise()
plugin::patch::RedirectCall(0x43FDFC, ShouldOverrideRestart);
plugin::patch::RedirectCall(0x444A7D, ShouldOverrideRestart);
plugin::patch::RedirectCall(0x444AAD, ShouldRestartCritical);
plugin::patch::Nop(0x588C25, 5); // Purple Nine's Glitch Fix

mTempMissionData = std::make_unique<unsigned char[]>(SIZE_MISSION_SCRIPT);
mLocalVariables = std::make_unique<unsigned int[]>(16);
Expand Down
1 change: 1 addition & 0 deletions src/Missions.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Missions : Functions
static void ResetGangThreatStates();
static void OpenPortlandSafehouseDoor();
static void FixEndOfMissions();
static void RemoveBridgeObstacles();

public:
static void Initialise();
Expand Down
14 changes: 12 additions & 2 deletions src/Pickups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ int Pickups::RandomizePickups(CVector posn, int modelID, int arg3, int ammo)
{
if (modelID == original_pickups[i])
{
newPickup = allowed_pickups[RandomNumber(0, allowed_pickups.size() - 1)];
if (Config::pickups.usingSeed)
newPickup = allowed_pickups[GetRandomUsingCustomSeed(0, allowed_pickups.size() - 1)];
else
newPickup = allowed_pickups[RandomNumber(0, allowed_pickups.size() - 1)];

if (CTheScripts::pActiveScripts->m_szName == std::string("cat1") && modelID == 175)
if (CTheScripts::pActiveScripts->m_szName == std::string("cat1") && modelID == 175
&& (int)posn.x == -1149 && (int)posn.y == 347 && (int)posn.z == 30)
{
newPickup = modelID;
ammo = 1;
Expand Down Expand Up @@ -41,6 +45,12 @@ bool Pickups::GivePlayerGoodiesWithPickUpMI(unsigned short model, int plrIndex)
{
return plugin::CallAndReturn<bool, 0x4339F0>(model, plrIndex);
}
int Pickups::GetRandomUsingCustomSeed(int min, int max)
{
static std::mt19937 pickupsEngine{ std::hash<std::string>{}(Config::pickups.seed) };
std::uniform_int_distribution<int> random(min, max);
return random(pickupsEngine);
}
void Pickups::Initialise()
{
if (Config::pickups.Enabled)
Expand Down
1 change: 1 addition & 0 deletions src/Pickups.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Pickups : Functions
private:
static int RandomizePickups(CVector posn, int modelID, int arg3, int ammo);
static int GenerateNewOne(CVector posn, int modelID, int arg3, int ammo);
static int GetRandomUsingCustomSeed(int min, int max);
static bool GiveMoneyForBriefcase(unsigned short model, int plrIndex);
static bool GivePlayerGoodiesWithPickUpMI(unsigned short model, int plrIndex);
static std::vector<int> original_pickups;
Expand Down
5 changes: 4 additions & 1 deletion src/default_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ EnableBriefcase = true
# Randomize a small amount of money given by a briefcase pickup
MoneyInBriefcase = true

# Enter your own seed - if empty, the seed will be random
PickupsCustomSeed = ""

###########################################
# Cutscene Randomizer
CutsceneRandomizer = true
Expand All @@ -119,7 +122,7 @@ RandomizeCopPeds = true
MissionRandomizer = true

# Enter your own seed - if empty, the seed will be random
CustomSeed = ""
MissionCustomSeed = ""

# Force a specific mission
ForcedMission = 0
Expand Down

0 comments on commit 15f344d

Please sign in to comment.