Skip to content

Commit

Permalink
Fixed Chao Back ring 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Feb 25, 2020
1 parent 16cce6d commit d0caf9c
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 43 deletions.
13 changes: 12 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
Bug report: https://github.com/Sora-yx/SADX-Randomizer/issues
Bug Report: https://github.com/Sora-yx/SADX-Randomizer/issues
V2.1.1

General:
- Chao Gameplay Mod is now compatible with the Randomizer, get ready to have your Chao following your Randomized adventure!

Bug fixes:
- Fixed a bug where the Lost Chao was spawned in a different location after a restart.
- Twinkle Park should now have a Back Ring for every character.
- Fixed a bug where finishing a stage as Amy could make the game crash.
- Adding a way to prevent the player to grab the Back Ring while having 100 Rings collected during Mission 2.


V2.1.0

Expand Down
5 changes: 3 additions & 2 deletions sadx-randomizer/03_TwinklePark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void TwinklePark_Layout() {

fixTCCart();

CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;
short RNGLayoutTP = randomizedSets[levelCount].Layout;
CurrentLevelLayout = 2; //randomizedSets[levelCount].MissionLayout;

TPAmyVersion = false;
TPBigVersion = false;

Expand Down Expand Up @@ -117,6 +117,7 @@ void TwinklePark_Layout() {
}
else
{
short RNGLayoutTP = randomizedSets[levelCount].Layout;
if (!RNGLayoutTP)
{
LoadSetFile(1, "0306"); //Big TP version
Expand Down
2 changes: 1 addition & 1 deletion sadx-randomizer/04_SpeedHighway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void __cdecl SpeedHighway_Init(const char* path, const HelperFunctions& helperFu

void SpeedHighway_Layout() {

CurrentLevelLayout = 3; //randomizedSets[levelCount].MissionLayout;
CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;

if (CurrentAct != 2)
{
Expand Down
2 changes: 1 addition & 1 deletion sadx-randomizer/06_SkyDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void SkyDeckCannonS2_LoadWithTarget(ObjectMaster* SDCanonnObj) {

void SkyDeck_Layout() {

CurrentLevelLayout = 3; //randomizedSets[levelCount].MissionLayout;
CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;

if (CurrentAct != 2)
{
Expand Down
6 changes: 6 additions & 0 deletions sadx-randomizer/09_Casino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ReplaceCAM(C, D) helperFunctions.ReplaceFile("system\\" C ".bin", "system\\cam\\" D ".bin")

ObjectMaster* TriggerCasino = nullptr;
bool CasinoTails = false;

void TriggerCasinoChao_Main(ObjectMaster* obj) {

Expand Down Expand Up @@ -64,10 +65,14 @@ void FixShakeoffGarbageAction() { //This make the game crash as Tails.

void Casino_Layout() {

CasinoTails = false;

CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;

if (CurrentAct == 1)
{
CasinoTails = true;

switch (CurrentLevelLayout)
{
case Mission1:
Expand Down Expand Up @@ -100,6 +105,7 @@ void Casino_Layout() {

if (CurrentAct == 0)
{
CasinoTails = false;
if (CurrentCharacter == Characters_Sonic && !Vanilla)
{
Race = false;
Expand Down
3 changes: 2 additions & 1 deletion sadx-randomizer/10_FinalEgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void FinalEgg_Layout() {
FEGammaVersion = false;

CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;
short RNGLayoutFE = randomizedSets[levelCount].Layout;


if (CurrentAct != 2)
{
Expand Down Expand Up @@ -87,6 +87,7 @@ void FinalEgg_Layout() {
break;
case Mission2_100Rings:
case Mission3_LostChao:
short RNGLayoutFE = randomizedSets[levelCount].Layout;
if (RNGLayoutFE)
{
FEAmyVersion = false;
Expand Down
8 changes: 5 additions & 3 deletions sadx-randomizer/12_HotShelter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void HotShelter_Layout() {
HSAmyVersion = false;
HSBigVersion = false;

//act 1 Amy/Big Version
CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;
short RNGLayoutHS = randomizedSets[levelCount].Layout;

CurrentLevelLayout = randomizedSets[levelCount].MissionLayout;

//act 1 Amy/Big Version
if (CurrentAct == 0)
{
//Prevent Amy and Big to get their original vanilla layout
Expand Down Expand Up @@ -114,6 +114,8 @@ void HotShelter_Layout() {

if (CurrentCharacter != Characters_Amy && CurrentCharacter != Characters_Big || Vanilla)
{
short RNGLayoutHS = randomizedSets[levelCount].Layout;

switch (CurrentLevelLayout)
{
case Mission1: //Amy Version
Expand Down
7 changes: 4 additions & 3 deletions sadx-randomizer/AISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int CheckTailsAI_R(void) { //restriction and bug fixes.
return 0;
}

if (CurrentAct == 0 && (CurrentAI == Characters_Amy || CurrentCharacter == Characters_Amy))
if (CurrentAct < 2 && !TreasureHunting && (CurrentAI == Characters_Amy || CurrentCharacter == Characters_Amy))
{
isAIActive = false;
return 0;
Expand Down Expand Up @@ -512,10 +512,11 @@ void FixAISFXAmy8() { //spin dash noise when you press B
PlaySound(0x509, 0, 0, 0);
}

bool isZeroActive = false;

void FixAISFXGamma() {

if (Race && CurrentCharacter != Characters_Gamma)
if (Race && CurrentCharacter != Characters_Gamma || isZeroActive)
return;

PlaySound(0x33b, 0, 0, 0);
Expand All @@ -525,7 +526,7 @@ void FixAISFXGamma() {

void FixAISFXGamma2() {

if (Race && CurrentCharacter != Characters_Gamma)
if (Race && CurrentCharacter != Characters_Gamma || isZeroActive)
return;

PlaySound(0x33d, 0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion sadx-randomizer/BackRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void BackRingObj_Main(ObjectMaster* obj) {

if (IsPlayerInsideSphere(&v1->Position, 42) && obj->Data1->Action == 0)
{
if (CurrentLevelLayout >= Mission2_100Rings)
if (CurrentLevelLayout == Mission2_100Rings && Rings < 100 || CurrentLevelLayout == Mission3_LostChao)
{
isBackRingTextureLoaded = false;
GetBackRing = true;
Expand Down
36 changes: 21 additions & 15 deletions sadx-randomizer/Chao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "data\chao.h"
#include "RandomHelpers.h"
#include "Trampoline.h"
#include <fstream>
#include <iostream>

ObjectMaster* ChaoObject;
ObjectMaster* CurrentChao;
Expand All @@ -13,6 +15,7 @@ short ChaoCryDelay = 0;
bool ArePvpLoaded = false;
extern int chaoPB;
bool ChaoSpawn = false;
extern bool CasinoTails;


ObjectMaster* ChaoTP = nullptr;
Expand All @@ -21,17 +24,22 @@ std::vector<NJS_PLANE> waterlist = {};

ChaoHandle ChaoMaster;

void ChaoGameplayCheck() {
bool DoesConfigExist(const std::string& file)
{
std::ifstream fichier(file.c_str());
return !fichier.fail();
}

void __cdecl ChaoGameplayCheck() {

HMODULE ChaoGameplay = GetModuleHandle(L"sadx-chao-gameplay");

if (ChaoGameplay && !isChaoGameplayAllowed) {
int msgboxID = MessageBoxA(WindowHandle, "Chao Gameplay Mod has been detected, would you like to pick your Chao before starting your Randomizer Adventure?", "SADX Randomizer", MB_YESNO);

switch (msgboxID)
{
case IDYES:
isChaoGameplayAllowed = true;
MessageBoxA(WindowHandle, "Randomizer will now send you to the Chao Garden when starting a new story. You can disable this in the settings.", "SADX Randomizer", MB_ICONINFORMATION);
break;
case IDNO:
default:
Expand All @@ -44,6 +52,7 @@ void ChaoGameplayCheck() {
{
MessageBoxA(WindowHandle, "Couldn't find Chao Gameplay Mod, make sure the mod is checked and installed.", "SADX Randomizer Error", MB_ICONERROR);
}

}

//This is where all the stuff to load "Lost Chao" mission is managed, Thanks to Kell for making a big part of the code here.
Expand Down Expand Up @@ -321,7 +330,7 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
Yrot = 0x8000;
ChaoSpawn = true;
}
else
if (CurAct == 0)
{
ChaoSpawn = false;
}
Expand All @@ -345,13 +354,13 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
Yrot = 0x8000;
ChaoSpawn = true;
}
if (CurAct == 1 && CasinoSwitch == 3)
if (CurAct == 1 && CasinoSwitch == 3 && CasinoTails)
{
pos = { -1565.96, -2205, 2654.24 };
Yrot = 0x8000;
ChaoSpawn = true;
}
else
if (CurAct > 1 || CurrentAct == 1 && !CasinoTails)
{
ChaoSpawn = false;
}
Expand All @@ -369,7 +378,7 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
Yrot = 0x8000;
ChaoSpawn = true;
}
else
if (CurAct == 0 || CurAct == 2)
{
ChaoSpawn = false;
}
Expand All @@ -394,7 +403,7 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
LoadChaoTPTrigger();
ChaoSpawn = true;
}
else
if (CurAct == 0)
{
ChaoSpawn = false;
}
Expand Down Expand Up @@ -469,7 +478,7 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
pos = { 2945.652344, 5589.605469, -2211.165039 };
ChaoSpawn = true;
}
else
if (CurAct == 1 || CurAct == 0 && !FEAmyVersion)
{
ChaoSpawn = false;
}
Expand Down Expand Up @@ -497,10 +506,7 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
ChaoSpawn = true;
}
}
else
{
ChaoSpawn = false;
}

if (CurAct == 0 && HSBigVersion)
{
if (CurrentCharacter != Characters_Gamma)
Expand All @@ -514,14 +520,14 @@ bool isChaoAllowedtoSpawn(short CurLevel, short CurAct)
ChaoSpawn = true;
}
}
else

if (CurAct == 0 && !HSBigVersion || CurAct == 1 && !HSAmyVersion)
{
ChaoSpawn = false;
}
break;
default:
ChaoSpawn = false;
return ChaoSpawn;
break;
}

Expand Down
14 changes: 6 additions & 8 deletions sadx-randomizer/Missions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,22 @@ void MissionResultCheck() {

if ((ent->Status & Status_Ground) == Status_Ground && (!isPlayerInWaterSlide && TimeThing != 0))
{
if (CurrentLevel == LevelIDs_TwinklePark && CurrentAct == 0)
{
LoadLevelResults();
if (CurrentLevel == LevelIDs_TwinklePark && CurrentAct == 0 && ent->Action >= 40 && ent->Action <= 60)
return;
}
else
{

ent->InvulnerableTime = 0;
if (!SonicRand && !MetalSonicFlag)
obj->Data1->Action = 0; //fix potential crash
obj->Data1->Status &= ~(Status_Attack | Status_Ball | Status_LightDash | Status_Unknown3);

if (++ent->InvulnerableTime == 1) //wait 1 frame before loading level result
{
if (!SonicRand && !MetalSonicFlag)
obj->Data1->Action = 1; //fix victory pose
LoadLevelResults();
LoadLevelResults_r();
return;
}
}

}
}

Expand Down
3 changes: 2 additions & 1 deletion sadx-randomizer/Mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ extern "C" {
srand((unsigned)time(&t));

SeedCopy = Seed;

//Activate all the edited stages, including custom object, to make them beatable, add custom audio and other stuff.
StartupLevels_Init(path, helperFunctions);
StartupAudio_Init(path, helperFunctions);
StartupMiscellaneous_Init(path, helperFunctions);

Chao_Init();
ChaoGameplayCheck();
Characters_Management();
Stages_Management();
RandomizeStages_Hook();
Expand Down
4 changes: 2 additions & 2 deletions sadx-randomizer/RandomHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void EggHornet_LoadWithTarget();
void Chaos0_LoadWithTarget();
void Chaos2_LoadWithTarget();
void Chaos6_LoadWithTarget();
void ChaoGameplayCheck();
void __cdecl ChaoGameplayCheck();

ObjectFunc(E101_Main, 0x567fd0);
VoidFunc(LoadE101, 0x568090);
Expand Down Expand Up @@ -306,7 +306,7 @@ void LoadStageMissionImage_r();
int LoadTitleCardTexture_r(int minDispTime);
void StageMissionImage_result();
int CheckMissionRequirements_r();

void __cdecl LoadLevelResults_r();

DataPointer(int, dword_3B2A304, 0x3B2A304);

Expand Down
Loading

0 comments on commit d0caf9c

Please sign in to comment.