Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Mar 10, 2020
1 parent ee9101f commit 543ae39
Show file tree
Hide file tree
Showing 39 changed files with 1,121 additions and 288 deletions.
2 changes: 0 additions & 2 deletions sadx-randomizer/01_EmeraldCoast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ void __cdecl EmeraldCoast_Init(const char* path, const HelperFunctions& helperFu
ReplaceCAM("CAM0102S", "CAM0102S");
ReplaceCAM("CAM0104S", "CAM0104S");

helperFunctions.RegisterStartPosition(Characters_Sonic, EC1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, EC2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, EC3_StartPositions[0]);

//Tails
Expand Down
19 changes: 16 additions & 3 deletions sadx-randomizer/02_WindyValley.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ void Cam_WV() {
return;
}

void FixTailsVictoryWV() {

//Prevent AI to make Tails lose when hiting the capsule if we aren't racing.

if (CurrentCharacter == Characters_Tails && !Race)
SetTailsRaceVictory();
else
SetOpponentRaceVictory();

return;
}



void WindyValley_Layout() {

Expand Down Expand Up @@ -73,16 +86,18 @@ void WindyValley_Layout() {
}

Cam_WV();

return;
}


void __cdecl WindyValley_Init(const char* path, const HelperFunctions& helperFunctions)
{
//Initiliaze data

WVObjects_Init(path, helperFunctions);
WriteCall((void*)0x422c27, WindyValley_Layout); //WV
WriteCall((void*)0x4df390, FixTailsVictoryWV);

//Sonic
helperFunctions.ReplaceFile("system\\SET0200S.BIN", "system\\levels\\Windy Valley\\Sonic-WV-Act1.bin");
Expand All @@ -102,8 +117,6 @@ void __cdecl WindyValley_Init(const char* path, const HelperFunctions& helperFun
if (!Vanilla)
helperFunctions.RegisterStartPosition(Characters_Sonic, WV1_StartPositions[0]);

helperFunctions.RegisterStartPosition(Characters_Sonic, WV2S_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, WV3S_StartPositions[0]);

//Tails
helperFunctions.ReplaceFile("system\\SET0200M.BIN", "system\\levels\\Windy Valley\\Tails-WV-Act1.bin");
Expand Down
4 changes: 3 additions & 1 deletion sadx-randomizer/03_TwinklePark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void TwinklePark_Layout() {
CurrentLevelLayout = Mission1;
break;
case Mission2_100Rings:
LoadSetFile(1, "0301");
break;
case Mission3_LostChao:
LoadSetFile(1, "0303"); //M3 Version
break;
Expand Down Expand Up @@ -177,7 +179,7 @@ void __cdecl TwinklePark_Init(const char* path, const HelperFunctions& helperFun
helperFunctions.ReplaceFile("system\\CAM0301S.BIN", "system\\cam\\CAM0301S.bin");
helperFunctions.ReplaceFile("system\\CAM0302S.BIN", "system\\cam\\CAM0302S.bin");
helperFunctions.ReplaceFile("system\\CAM0305S.BIN", "system\\cam\\CAM0305S.bin");
helperFunctions.RegisterStartPosition(Characters_Sonic, TP1_StartPositions[0]);

helperFunctions.RegisterStartPosition(Characters_Sonic, TP2S_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, TP3_StartPositions[0]);

Expand Down
21 changes: 17 additions & 4 deletions sadx-randomizer/04_SpeedHighway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "SH.h"
#include "RandomHelpers.h"
#include "ActsSettings.h"
#include "Trampoline.h"
#define ReplaceSET(A, B) helperFunctions.ReplaceFile("system\\" A ".bin", "system\\levels\\Speed Highway\\" B ".bin")
#define ReplaceCAM(C, D) helperFunctions.ReplaceFile("system\\" C ".bin", "system\\cam\\" D ".bin")

Expand All @@ -15,6 +16,19 @@ void SHAct2Position() {
return ForcePlayerAction(0, 0x2b);
}

void CheckEggmanRaceWinner() {

if (CurrentCharacter == Characters_Tails || !Race)
LoadLevelResults_r();

if (CurrentCharacter != Characters_Tails && Race)
{
if (CurrentLevel == LevelIDs_SpeedHighway && CurrentAct == 0 && RaceWinnerPlayer == 2)
{
SetAIRaceWin();
}
}
}

void CamSpeedHighway() {

Expand All @@ -37,6 +51,8 @@ void CamSpeedHighway() {
return;
}



void __cdecl SpeedHighway_Init(const char* path, const HelperFunctions& helperFunctions)
{
//Initiliaze data
Expand All @@ -51,6 +67,7 @@ void __cdecl SpeedHighway_Init(const char* path, const HelperFunctions& helperFu
WriteData<5>((void*)0x422cee, 0x90);

WriteCall((void*)0x422cfd, SpeedHighway_Layout); //SH random layout
WriteJump((void*)0x47d527, CheckEggmanRaceWinner);

SHObjects_Init(path, helperFunctions);

Expand All @@ -68,10 +85,6 @@ void __cdecl SpeedHighway_Init(const char* path, const HelperFunctions& helperFu
ReplaceCAM("CAM0405S", "CAM0405S");


helperFunctions.RegisterStartPosition(Characters_Sonic, SH1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, SH2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, SH3_StartPositions[0]);

//Tails
ReplaceSET("SET0400M", "Tails-SH-Act1");
ReplaceSET("SET0401M", "Tails-SH-Act2");
Expand Down
3 changes: 0 additions & 3 deletions sadx-randomizer/05_RedMountain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ void __cdecl RedMountain_Init(const char* path, const HelperFunctions& helperFun
ReplaceCAM("CAM0502S", "CAM0502S");
ReplaceCAM("CAM0503S", "CAM0503S");

RegisterPosition(Characters_Sonic, RM1_StartPositions[0]);
RegisterPosition(Characters_Sonic, RM2_StartPositions[0]);
RegisterPosition(Characters_Sonic, RM3_StartPositions[0]);

//Tails
Expand Down Expand Up @@ -95,7 +93,6 @@ void __cdecl RedMountain_Init(const char* path, const HelperFunctions& helperFun

RegisterPosition(Characters_Knuckles, RM1_StartPositions[0]);
RegisterPosition(Characters_Knuckles, RM2_StartPositions[0]);
RegisterPosition(Characters_Knuckles, RM3_StartPositions[0]);

//Amy
ReplaceSET("SET0500A", "Amy-RM-Act1");
Expand Down
24 changes: 19 additions & 5 deletions sadx-randomizer/06_SkyDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#define ReplaceSET(A, B) helperFunctions.ReplaceFile("system\\" A ".bin", "system\\levels\\Sky Deck\\" B ".bin")
#define ReplaceCAM(C, D) helperFunctions.ReplaceFile("system\\" C ".bin", "system\\cam\\" D ".bin")



void Cam_SkyDeck() {

if (Mission1_Variation && CurrentAct == 0 && Race)
Expand Down Expand Up @@ -82,6 +84,18 @@ void SkyDeckCannonS2_LoadWithTarget(ObjectMaster* SDCanonnObj) {
return;
}

void FixTailsVictorySD() {

//Prevent AI to make Tails lose when hiting the capsule if we aren't racing.

if (CurrentCharacter == Characters_Tails && !Race)
SetTailsRaceVictory();
else
SetOpponentRaceVictory();

return;
}


void SkyDeck_Layout() {

Expand Down Expand Up @@ -120,7 +134,7 @@ void SkyDeck_Layout() {
break;
case Mission2_100Rings:
case Mission3_LostChao:
if (CurrentCharacter == Characters_Sonic && !Vanilla)
if (CurrentCharacter == Characters_Sonic && !Vanilla || CurrentCharacter == Characters_Knuckles)
{
Race = true;
LoadSetFile(0, "0605"); //load Tails layout
Expand All @@ -146,7 +160,6 @@ void SkyDeck_Layout() {
LoadSetFile(0, "0600");
LoadSetFile(1, "0601");
LoadSetFile(2, "0604"); //Knuckles Version

}
else
{
Expand All @@ -173,6 +186,8 @@ void __cdecl SkyDeck_Init(const char* path, const HelperFunctions& helperFunctio
WriteJump((void*)0x5f8530, SkyDeckCannon_LoadWithTarget);
WriteJump((void*)0x5f9760, SkyDeckCannonS1_LoadWithTarget);
WriteJump((void*)0x5f8e50, SkyDeckCannonS2_LoadWithTarget);

WriteCall((void*)0x461614, FixTailsVictorySD);
SDObjects_Init(path, helperFunctions);

//Sonic
Expand All @@ -187,9 +202,8 @@ void __cdecl SkyDeck_Init(const char* path, const HelperFunctions& helperFunctio
ReplaceCAM("CAM0602S", "CAM0602S");
ReplaceCAM("CAM0603S", "CAM0603S");
ReplaceCAM("CAM0604S", "CAM0604S");

helperFunctions.RegisterStartPosition(Characters_Sonic, SD1S_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, SD2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, SD3_StartPositions[0]);

//Tails
ReplaceSET("SET0600M", "Tails-SD-Act1");
Expand All @@ -203,7 +217,7 @@ void __cdecl SkyDeck_Init(const char* path, const HelperFunctions& helperFunctio
ReplaceCAM("CAM0602M", "CAM0602M");
ReplaceCAM("CAM0603M", "CAM0603M");
ReplaceCAM("CAM0604M", "CAM0604M");
helperFunctions.RegisterStartPosition(Characters_Tails, SD1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Tails, SD1S_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Tails, SD2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Tails, SD3_StartPositions[0]);

Expand Down
4 changes: 0 additions & 4 deletions sadx-randomizer/07_LostWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ void __cdecl LostWorld_Init(const char* path, const HelperFunctions& helperFunct
ReplaceCAM("CAM0702S", "CAM0702S");
ReplaceCAM("CAM0704S", "CAM0704S");

helperFunctions.RegisterStartPosition(Characters_Sonic, LW1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, LW2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, LW3_StartPositions[0]);

//Tails
ReplaceSET("SET0700M", "Tails-LW-Act1");
ReplaceSET("SET0701M", "Tails-LW-Act2");
Expand Down
33 changes: 28 additions & 5 deletions sadx-randomizer/08_IceCap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "RandomHelpers.h"
#include "ActsSettings.h"
#include "CharactersSettings.h"
#include "Trampoline.h"



Expand Down Expand Up @@ -39,6 +40,15 @@ void DisableController_R() {
}
}

//Add rings every Checkpoint for cart speed.
void AddRingIceCap() {
PlaySound(0x15, 0, 0, 0);

if (CurrentLevel == LevelIDs_IceCap && CurrentCharacter > Characters_Tails)
AddRings(5);

return;
}


void ICAct3Position() {
Expand All @@ -57,6 +67,21 @@ void ICAct3Position() {
return;
}

void FixTailsVictoryIC() {

//Prevent AI to make Tails lose when hiting the capsule if we aren't racing.

if (CurrentCharacter == Characters_Tails && !Race)
SetTailsRaceVictory();
else
SetOpponentRaceVictory();

return;
}

VoidFunc(FUNC0043614, 0x043614);


void IC_Layout() {

if (CurrentAct != 3)
Expand Down Expand Up @@ -127,14 +152,14 @@ void IC_Layout() {
return;
}



void __cdecl IceCap_Init(const char* path, const HelperFunctions& helperFunctions)
{
//Initiliaze data

WriteCall((void*)0x4e92e7, IC_ReturnCharacter);
WriteCall((void*)0x4e9802, IC_ReturnCharacter);
WriteCall((void*)0x4ec065, AddRingIceCap);
WriteCall((void*)0x4ecf8f, FixTailsVictoryIC);

WriteData<5>((void*)0x422e66, 0x90);
WriteData<5>((void*)0x422e75, 0x90);
Expand All @@ -159,9 +184,7 @@ void __cdecl IceCap_Init(const char* path, const HelperFunctions& helperFunction
helperFunctions.ReplaceFile("system\\CAM0801S.BIN", "system\\cam\\CAM0801S.bin");
helperFunctions.ReplaceFile("system\\CAM0802S.BIN", "system\\cam\\CAM0802S.bin");
helperFunctions.ReplaceFile("system\\CAM0803S.BIN", "system\\cam\\CAM0803S.bin");
helperFunctions.RegisterStartPosition(Characters_Sonic, IC1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, IC2_StartPositions[0]);
//helperFunctions.RegisterStartPosition(Characters_Sonic, IC3_StartPositions[0]);

helperFunctions.RegisterStartPosition(Characters_Sonic, IC4_StartPositions[0]);

//Tails
Expand Down
18 changes: 16 additions & 2 deletions sadx-randomizer/09_Casino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ void FixInvisibleWall() {
return;
}


void FixTailsVictoryCAS() {

//Prevent AI to make Tails lose when hiting the capsule if we aren't racing.

if (CurrentCharacter == Characters_Tails && !Race)
SetTailsRaceVictory();
else
SetOpponentRaceVictory();

return;
}

void FixGoldenAndCoin() {

//if Knuckles layout, move the coin in the emerald room and display Sonic Golden Statue, else restore the original function.
Expand Down Expand Up @@ -258,6 +271,9 @@ void __cdecl Casino_Init(const char* path, const HelperFunctions& helperFunction
WriteCall((void*)0x5c14f5, IncreaseRings_R);

WriteCall((void*)0x5c5906, FixShakeoffGarbageAction);
WriteCall((void*)0x5dd088, FixTailsVictoryCAS);

WriteCall((void*)0x5dd08d, FixRaceResult);

CasinoObjects_Init(path, helperFunctions);

Expand All @@ -274,8 +290,6 @@ void __cdecl Casino_Init(const char* path, const HelperFunctions& helperFunction
ReplaceCAM("CAM0901S", "CAM0901S");
ReplaceCAM("CAM0906S", "CAM0906S");

helperFunctions.RegisterStartPosition(Characters_Sonic, Casino1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, Casino2_StartPositions[0]);

//Tails
ReplaceSET("SET0900M", "Tails-Casino-Act1");
Expand Down
2 changes: 0 additions & 2 deletions sadx-randomizer/10_FinalEgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ void __cdecl FinalEgg_Init(const char* path, const HelperFunctions& helperFuncti


helperFunctions.RegisterStartPosition(Characters_Sonic, FE1_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, FE2_StartPositions[0]);
helperFunctions.RegisterStartPosition(Characters_Sonic, FE3_StartPositions[0]);

//Tails
ReplaceSET("SET1000M", "Tails-FE-Act1");
Expand Down
13 changes: 7 additions & 6 deletions sadx-randomizer/AISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ void ResultVoiceFix() {
case Characters_Sonic:
if (MetalSonicFlag == 0) {
if ((short)CurrentLevel < 0xf) {
Load_DelayedSound_SFX(0x5d7);
Load_DelayedSound_Voice(1840);
}
else {
Load_DelayedSound_SFX(0x5da);
Load_DelayedSound_Voice(1843);
}
}
else {
Expand All @@ -590,9 +590,10 @@ void ResultVoiceFix() {
Load_DelayedSound_SFX(0x5a8);
break;
case Characters_Amy:
Load_DelayedSound_SFX(0x56e);
case Characters_Gamma:
Load_DelayedSound_SFX(0x591);
if (CurrentLevel >= LevelIDs_Chaos0)
Load_DelayedSound_Voice(1735);
else
Load_DelayedSound_Voice(1733);
break;
case Characters_Big:
if (CurrentLevel >= LevelIDs_Chaos0 || CurrentLevelLayout >= Mission2_100Rings || FEGammaVersion || TreasureHunting)
Expand Down Expand Up @@ -645,7 +646,7 @@ void AISwitch() {
if (CurrentCart)
return;

if (SonicRand == 0 && isAIActive && CurrentLevel != 15) //don't allow the swap if metal sonic / super sonic or if Chaos 0 fight (crash.)
if (SonicRand == 0 && isAIActive) //don't allow the swap if metal sonic / super sonic
{
//initialize swap, taking actual character and ai information

Expand Down
Loading

0 comments on commit 543ae39

Please sign in to comment.