Skip to content

Commit

Permalink
Merge pull request #83 from cjohnson57/random-starting-age
Browse files Browse the repository at this point in the history
settings: Add random starting age option
  • Loading branch information
gamestabled authored Mar 28, 2021
2 parents eda15eb + cd968b4 commit b7a198e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion code/src/savefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void SaveFile_Init() {
gSaveContext.eventChkInf[0x4] |= 0x2000;
}

if (gSettingsContext.startingAge == AGE_ADULT) {
if (gSettingsContext.resolvedStartingAge == AGE_ADULT) {
gSaveContext.linkAge = AGE_ADULT; //age is adult
gSaveContext.entranceIndex = 0xF4050000; //spawn at temple of time
gSaveContext.sceneIndex = 0x6100; //^
Expand Down
2 changes: 2 additions & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef enum {
typedef enum {
AGE_ADULT,
AGE_CHILD,
AGE_RANDOM,
} AgeSetting;

typedef enum {
Expand Down Expand Up @@ -171,6 +172,7 @@ typedef struct {
u8 ganonsTrialsCount;

u8 startingAge;
u8 resolvedStartingAge;
u8 bombchusInLogic;
u8 bombchuDrops;
u8 randomMQDungeons;
Expand Down
8 changes: 4 additions & 4 deletions source/location_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2698,13 +2698,13 @@ namespace Exits { //name, scene, hint, events, locations, exits
}

if(Settings::HasNightStart) {
if(Settings::StartingAge.Is(AGE_CHILD)) {
if(Settings::ResolvedStartingAge == AGE_CHILD) {
Exits::Root.nightChild = true;
} else {
Exits::Root.nightAdult = true;
}
} else {
if(Settings::StartingAge.Is(AGE_CHILD)) {
if(Settings::ResolvedStartingAge == AGE_CHILD) {
Exits::Root.dayChild = true;
} else {
Exits::Root.dayAdult = true;
Expand All @@ -2724,13 +2724,13 @@ namespace Exits { //name, scene, hint, events, locations, exits
}

if(Settings::HasNightStart) {
if(Settings::StartingAge.Is(AGE_CHILD)) {
if(Settings::ResolvedStartingAge == AGE_CHILD) {
Exits::Root.nightChild = true;
} else {
Exits::Root.nightAdult = true;
}
} else {
if(Settings::StartingAge.Is(AGE_CHILD)) {
if(Settings::ResolvedStartingAge == AGE_CHILD) {
Exits::Root.dayChild = true;
} else {
Exits::Root.dayAdult = true;
Expand Down
5 changes: 1 addition & 4 deletions source/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ namespace Logic {
//Other
bool AtDay = false;
bool AtNight = false;
bool IsStartingAge = false;
u8 Age = 0;

//Events
Expand Down Expand Up @@ -426,7 +425,6 @@ namespace Logic {

IsChild = Age == AGE_CHILD;
IsAdult = Age == AGE_ADULT;
IsStartingAge = StartingAge.Is(Age); //what's this for?

//IsGlitched = false;

Expand Down Expand Up @@ -755,8 +753,7 @@ namespace Logic {
//Other
AtDay = false;
AtNight = false;
IsStartingAge = false;
Age = Settings::StartingAge.Value<u8>();
Age = Settings::ResolvedStartingAge;

//Events
ShowedMidoSwordAndShield = false;
Expand Down
2 changes: 0 additions & 2 deletions source/logic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ namespace Logic {
extern bool HasExplosives;
extern bool IsChild;
extern bool IsAdult;
extern bool IsStartingAge;
//extern bool IsGlitched;
extern bool CanBlastOrSmash;
extern bool CanChildAttack;
Expand Down Expand Up @@ -264,7 +263,6 @@ namespace Logic {
extern bool ChildWaterTemple;
extern bool RaiseWaterLevel;
extern bool KingZoraThawed;
extern bool IsStartingAge;
extern bool AtDampeTime;
extern bool DeliverLetter;
extern bool KakarikoVillageGateOpen;
Expand Down
18 changes: 17 additions & 1 deletion source/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace Settings {
};

//World Settings
Option StartingAge = Option::U8 ("Starting Age", {"Adult", "Child"}, {ageDesc, ageDesc});
Option StartingAge = Option::U8 ("Starting Age", {"Adult", "Child", "Random"}, {ageDesc, ageDesc, ageDesc});
u8 ResolvedStartingAge;
Option BombchusInLogic = Option::Bool("Bombchus in Logic", {"Off", "On"}, {bombchuLogicDesc, bombchuLogicDesc});
Option BombchuDrops = Option::Bool("Bombchu Drops", {"Off", "On"}, {bombchuDropDesc, bombchuDropDesc});
Option RandomMQDungeons = Option::Bool("Random MQ Dungeons", {"Off", "On"}, {randomMQDungeonsDesc, randomMQDungeonsDesc});
Expand Down Expand Up @@ -372,6 +373,8 @@ namespace Settings {
ctx.ganonsTrialsCount = GanonsTrialsCount.Value<u8>();

ctx.startingAge = StartingAge.Value<u8>();
ctx.resolvedStartingAge = ResolvedStartingAge;

ctx.bombchusInLogic = (BombchusInLogic) ? 1 : 0;
ctx.bombchuDrops = (BombchuDrops) ? 1 : 0;
ctx.randomMQDungeons = (RandomMQDungeons) ? 1 : 0;
Expand Down Expand Up @@ -800,6 +803,19 @@ namespace Settings {
*trialsSkipped[i] = false; //the selected trial is not skipped
}

if (StartingAge.Is(AGE_RANDOM)) {
int choice = Random(0, 2); //50% chance of each
if (choice == 0) {
ResolvedStartingAge = AGE_CHILD;
}
else {
ResolvedStartingAge = AGE_ADULT;
}
}
else {
ResolvedStartingAge = StartingAge.Value<u8>();
}

HasNightStart = StartingTime.Is(STARTINGTIME_NIGHT);

if (GanonsBossKey.Is(GANONSBOSSKEY_LACS_MEDALLIONS)) {
Expand Down
1 change: 1 addition & 0 deletions source/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ namespace Settings {
extern Option GanonsTrialsCount;

extern Option StartingAge;
extern u8 ResolvedStartingAge;
extern Option BombchusInLogic;
extern Option BombchuDrops;
extern Option RandomMQDungeons;
Expand Down

0 comments on commit b7a198e

Please sign in to comment.