Skip to content

Commit

Permalink
Hint Stone Implementation (#21)
Browse files Browse the repository at this point in the history
* Add in new hints. Update z3dr.

* Begin attempting to insert hints.

* Partially working hints again.

Need to fix crashes on hint generation. May need to start from scratch.

* Hint List Update

-Adds in the key list into Hint_List.cpp so that they can be converted into hintTable entries.
-Adds the NewItem function to Item_list.cpp
-Adds gossip stones into Location_Access.cpp for availability

* Include boss hint and dungeon hint text.

* Sometimes Hints1

Adds location hints from clocktower to GBC

* Update hint_list.cpp

change location Keys into preformed empty hintTable entries so only text needs to be entered instead of changing the whole line

* Update hint_list.cpp

align hintTable entries to start on column 5

* Update hint_list.cpp

Add missing Dungeon Locations
Also filled out Ikana Canyon, Ikana Graveyard, Laundry Pool, and all Great Fairy Locations

* Update hint_list.cpp

completed overworld locations

* Update hint_list.cpp

dungeon locations added

* Update hint_list.cpp

everything except junk

* update hint_list.cpp

add extra spaces for text to be copied into as it errors with only one option

* Remove some debug statements.

Include new items in hint table to prevent crashing.

* Finalize hints, there is still more issues with locations I believe now.

* Missed dungeon items.

* Hint List Updates

- Adds more missing item hint table entries.
- Changes dungeon HintText type to Exclude instead of Sometimes to better match OOT3DR
- Adds a few missing items from Item Table
- Adjusts array sizes on progressiveItemsList and moonItemList to match contents so no more "No Items" get placed
- uncomments Hint Distriubution and ClearerHints settings

* Adjust hint text box to match gossip stones.

Add more debug statements to look for potential blank areas and no hint areas.

* Adjust debug prints.

* Fix broken build.

* Hints Fix

-Adjusts GossipStoneHintsSetting in fill.cpp to account for No Hints setting
- Adjusts a hint key for some areatable declarations to fix No Hint issues
- Adjusts print lines for generation text to look nicer
- removes WIP text from gossip stones
- removes ClearerHints option as it doesnt work yet
- Uncomments hint writing to spoiler log as they work now

* Add in new hints. Update z3dr.

* Begin attempting to insert hints.

* Partially working hints again.

Need to fix crashes on hint generation. May need to start from scratch.

* Hint List Update

-Adds in the key list into Hint_List.cpp so that they can be converted into hintTable entries.
-Adds the NewItem function to Item_list.cpp
-Adds gossip stones into Location_Access.cpp for availability

* Include boss hint and dungeon hint text.

* Sometimes Hints1

Adds location hints from clocktower to GBC

* Update hint_list.cpp

change location Keys into preformed empty hintTable entries so only text needs to be entered instead of changing the whole line

* Update hint_list.cpp

align hintTable entries to start on column 5

* Update hint_list.cpp

Add missing Dungeon Locations
Also filled out Ikana Canyon, Ikana Graveyard, Laundry Pool, and all Great Fairy Locations

* Update hint_list.cpp

completed overworld locations

* Update hint_list.cpp

dungeon locations added

* Update hint_list.cpp

everything except junk

* update hint_list.cpp

add extra spaces for text to be copied into as it errors with only one option

* Remove some debug statements.

Include new items in hint table to prevent crashing.

* Finalize hints, there is still more issues with locations I believe now.

* Missed dungeon items.

* Hint List Updates

- Adds more missing item hint table entries.
- Changes dungeon HintText type to Exclude instead of Sometimes to better match OOT3DR
- Adds a few missing items from Item Table
- Adjusts array sizes on progressiveItemsList and moonItemList to match contents so no more "No Items" get placed
- uncomments Hint Distriubution and ClearerHints settings

* Adjust hint text box to match gossip stones.

Add more debug statements to look for potential blank areas and no hint areas.

* Adjust debug prints.

* Fix broken build.

* Hints Fix

-Adjusts GossipStoneHintsSetting in fill.cpp to account for No Hints setting
- Adjusts a hint key for some areatable declarations to fix No Hint issues
- Adjusts print lines for generation text to look nicer
- removes WIP text from gossip stones
- removes ClearerHints option as it doesnt work yet
- Uncomments hint writing to spoiler log as they work now

* Include more hints.

Include a hack fix for including the B button in junk hints.

* Update subrepo once more.

* Update hint_list.cpp

Adds more junk hints and fixes phrasing on location text

* Reset subrepo.

* Add in a few more hints.

* Moar hints.

* Finish the junk hints.

* Jumk

---------

Co-authored-by: Tacoman369 <90735287+Tacoman369@users.noreply.github.com>
  • Loading branch information
PhlexPlexico and Tacoman369 authored Jan 18, 2024
1 parent 4df687f commit 71eafc2
Show file tree
Hide file tree
Showing 16 changed files with 969 additions and 277 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "Z3DR"]
path = Z3DR
url = https://github.com/Z3DR/mm3dr.git
branch = dev
8 changes: 4 additions & 4 deletions source/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,12 @@ int Fill() {
CreateItemOverrides();
// CreateEntranceOverrides();
// CreateAlwaysIncludedMessages();
/*if (GossipStoneHints.IsNot(HINTS_NO_HINTS)) {
printf("\x1b[10;10HCreating Hints...");
if (GossipStoneHints.IsNot(rnd::GossipStoneHintsSetting::HINTS_NO_HINTS)) {
printf("\x1b[11;10HCreating Hints...");
CreateAllHints();
printf("Done");
}
if (ShuffleMerchants.Is(SHUFFLEMERCHANTS_HINTS)) {
}
/*if (ShuffleMerchants.Is(SHUFFLEMERCHANTS_HINTS)) {
CreateMerchantsHints();
}*/
return 1;
Expand Down
955 changes: 771 additions & 184 deletions source/hint_list.cpp

Large diffs are not rendered by default.

69 changes: 46 additions & 23 deletions source/hints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "spoiler_log.hpp"
#include "fill.hpp"
#include "hint_list.hpp"
#include "custom_messages.hpp"
//#include "trial.hpp"
//#include "entrance.hpp"

Expand Down Expand Up @@ -122,8 +123,8 @@ static Area* GetHintRegion(const AreaKey area) {
}

//add unchecked exits to spot queue
//bool checked = false;
/*
bool checked = false;

for (auto& exit : AreaTable(region)->exits) {
for (AreaKey checkedExit : alreadyChecked) {
if (exit.GetAreaKey() == checkedExit) {
Expand All @@ -135,9 +136,8 @@ static Area* GetHintRegion(const AreaKey area) {
if (!checked) {
spotQueue.insert(spotQueue.begin(), exit.GetAreaKey());
}
}*/
}
}

return AreaTable(NONE);
}

Expand All @@ -155,17 +155,23 @@ static std::vector<LocationKey> GetAccessibleGossipStones(const LocationKey hint
return accessibleGossipStones;
}

/*static void AddHint(Text hint, const LocationKey gossipStone, const std::vector<u8>& colors = {}) {
static void AddHint(Text hint, const LocationKey gossipStone, const std::vector<colType>& colors = {}) {
//save hints as dummy items for writing to the spoiler log
//NewItem(gossipStone, Item{hint, ITEMTYPE_EVENT, GI_RUPEE_BLUE_LOSE, false, &noVariable, NONE});
NewItem(gossipStone, Item{ false, true, &noVariable, hint, NONE, (u32)GetItemID::GI_RUPEE_BLUE, ITEMTYPE_EVENT, (u16)0});
Location(gossipStone)->SetPlacedItem(gossipStone);

//create the in game message
//u32 messageId = 0x400 + Location(gossipStone)->GetFlag();
u16 messageId = Location(gossipStone)->GetTextID();
std::vector<iconType> icons = {};
//u32 sariaMessageId = 0xA00 + Location(gossipStone)->GetFlag();
CitraPrint("Our hint text is " + hint.GetEnglish());
if (hint.GetEnglish().find("$")) {
icons.push_back(B_BUTTON);
}
CustomMessages::CreateMessage(messageId, 0xFFFF, 0x3FFFFFFF, 0xFF0020, hint.GetEnglish().c_str(), colors, icons, {}, 0x0, false, false);
//CreateMessageFromTextObject(messageId, 0, 2, 3, AddColorsAndFormat(hint, colors));
//CreateMessageFromTextObject(sariaMessageId, 0, 2, 3, AddColorsAndFormat(hint + EVENT_TRIGGER(), colors));
}*/
}

static void CreateLocationHint(const std::vector<LocationKey>& possibleHintLocations) {
//return if there aren't any hintable locations or gossip stones available
Expand All @@ -190,7 +196,7 @@ static void CreateLocationHint(const std::vector<LocationKey>& possibleHintLocat
return;
}

//LocationKey gossipStone = RandomElement(accessibleGossipStones);
LocationKey gossipStone = RandomElement(accessibleGossipStones);
Location(hintedLocation)->SetAsHinted();

//make hint text
Expand All @@ -203,7 +209,7 @@ static void CreateLocationHint(const std::vector<LocationKey>& possibleHintLocat
PlacementLog_Msg(finalHint.english);
PlacementLog_Msg("\n\n");

//AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED});
AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED});
}

static void CreateWothHint(u8* remainingDungeonWothHints) {
Expand Down Expand Up @@ -240,24 +246,26 @@ static void CreateWothHint(u8* remainingDungeonWothHints) {
return;
}
Location(hintedLocation)->SetAsHinted();
//LocationKey gossipStone = RandomElement(gossipStoneLocations);
LocationKey gossipStone = RandomElement(gossipStoneLocations);

//form hint text
Text locationText;
if (Location(hintedLocation)->IsDungeon()) {
*remainingDungeonWothHints -= 1;
AreaKey parentRegion = Location(hintedLocation)->GetParentRegionKey();
CitraPrint("WoTH Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(parentRegion)->GetName());
locationText = AreaTable(parentRegion)->GetHint().GetText();

} else {
AreaKey parentRegion = Location(hintedLocation)->GetParentRegionKey();
CitraPrint("WoTH Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(parentRegion)->GetName());
locationText = GetHintRegion(parentRegion)->GetHint().GetText();
}
Text finalWothHint = Hint(PREFIX).GetText()+"#"+locationText+"#"+Hint(WAY_OF_THE_HERO).GetText();
PlacementLog_Msg("\tMessage: ");
PlacementLog_Msg(finalWothHint.english);
PlacementLog_Msg("\n\n");
//AddHint(finalWothHint, gossipStone, {QM_LBLUE});
AddHint(finalWothHint, gossipStone, {QM_BLUE});
}

static void CreateBarrenHint(u8* remainingDungeonBarrenHints, std::vector<LocationKey>& barrenLocations) {
Expand Down Expand Up @@ -287,23 +295,25 @@ static void CreateBarrenHint(u8* remainingDungeonBarrenHints, std::vector<Locati
return;
}
Location(hintedLocation)->SetAsHinted();
//LocationKey gossipStone = RandomElement(gossipStoneLocations);
LocationKey gossipStone = RandomElement(gossipStoneLocations);

//form hint text
Text locationText;
if (Location(hintedLocation)->IsDungeon()) {
*remainingDungeonBarrenHints -= 1;
AreaKey parentRegion = Location(hintedLocation)->GetParentRegionKey();
CitraPrint("Barrent Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(parentRegion)->GetName());
locationText = Hint(AreaTable(parentRegion)->hintKey).GetText();
} else {
AreaKey parentRegion = Location(hintedLocation)->GetParentRegionKey();
CitraPrint("Barrent Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(parentRegion)->GetName());
locationText = Hint(GetHintRegion(parentRegion)->hintKey).GetText();
}
Text finalBarrenHint = Hint(PREFIX).GetText()+Hint(PLUNDERING).GetText()+"#"+locationText+"#"+Hint(FOOLISH).GetText();
PlacementLog_Msg("\tMessage: ");
PlacementLog_Msg(finalBarrenHint.english);
PlacementLog_Msg("\n\n");
//AddHint(finalBarrenHint, gossipStone, {QM_PINK});
AddHint(finalBarrenHint, gossipStone, {QM_RED});

//get rid of all other locations in this same barren region
barrenLocations = FilterFromPool(barrenLocations, [hintedLocation](LocationKey loc){
Expand Down Expand Up @@ -338,25 +348,34 @@ static void CreateRandomLocationHint(const bool goodItem = false) {
return;
}
Location(hintedLocation)->SetAsHinted();
//LocationKey gossipStone = RandomElement(gossipStoneLocations);
LocationKey gossipStone = RandomElement(gossipStoneLocations);

//form hint text
/* CitraPrint("Checking location " + Location(hintedLocation)->GetName() + \
"'s item which is " + Location(hintedLocation)->GetPlacedItemName().GetEnglish() + \
" and GetItemID of " + Location(hintedLocation)->GetPlacedItem().GetItemId() + "\n");
DebugPrint("Checking location %s's item which is %s and GetItemID of %#04x and hint text is %s\n", Location(hintedLocation)->GetName().c_str(), \
Location(hintedLocation)->GetPlacedItemName().GetEnglish().c_str(), \
Location(hintedLocation)->GetPlacedItem().GetItemId(), \
Location(hintedLocation)->GetPlacedItem().GetHint().GetText().GetEnglish().c_str()); */
Text itemText = Location(hintedLocation)->GetPlacedItem().GetHint().GetText();
if (Location(hintedLocation)->IsDungeon()) {
AreaKey parentRegion = Location(hintedLocation)->GetParentRegionKey();
Text locationText = AreaTable(parentRegion)->GetHint().GetText();
CitraPrint("Random Loc Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(parentRegion)->GetName());
Text finalHint = Hint(PREFIX).GetText()+"#"+locationText+"# "+Hint(HOARDS).GetText()+" #"+itemText+"#.";
PlacementLog_Msg("\tMessage: ");
PlacementLog_Msg(finalHint.english);
PlacementLog_Msg("\n\n");
//AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED});
AddHint(finalHint, gossipStone, {QM_GREEN, QM_RED});
} else {
CitraPrint("Random Loc Hint: Getting " + Location(hintedLocation)->GetName() + "'s parent region which is " + Location(Location(hintedLocation)->GetParentRegionKey())->GetName());
Text locationText = GetHintRegion(Location(hintedLocation)->GetParentRegionKey())->GetHint().GetText();
Text finalHint = Hint(PREFIX).GetText()+"#"+itemText+"# "+Hint(CAN_BE_FOUND_AT).GetText()+" #"+locationText+"#.";
PlacementLog_Msg("\tMessage: ");
PlacementLog_Msg(finalHint.english);
PlacementLog_Msg("\n\n");
//AddHint(finalHint, gossipStone, {QM_RED, QM_GREEN});
AddHint(finalHint, gossipStone, {QM_RED, QM_GREEN});
}
}

Expand All @@ -367,20 +386,25 @@ static void CreateGoodItemHint() {
static void CreateJunkHint() {
//duplicate junk hints are possible for now
const HintText junkHint = RandomElement(GetHintCategory(HintCategory::Junk));

LogicReset();
const std::vector<LocationKey> gossipStones = GetAccessibleLocations(gossipStoneLocations);
if (gossipStones.empty()) {
PlacementLog_Msg("\tNO GOSSIP STONES TO PLACE HINT\n\n");
return;
}
//LocationKey gossipStone = RandomElement(gossipStones);
LocationKey gossipStone = RandomElement(gossipStones);
Text hint = junkHint.GetText();

PlacementLog_Msg("\tMessage: ");
PlacementLog_Msg(hint.english);
PlacementLog_Msg("\n");

PlacementLog_Msg("\tLocation: ");
PlacementLog_Msg(Location(gossipStone)->GetName());
PlacementLog_Msg("\n\n");

//AddHint(hint, gossipStone, {QM_PINK});
AddHint(hint, gossipStone, {QM_RED});
}

static std::vector<LocationKey> CalculateBarrenRegions() {
Expand Down Expand Up @@ -479,7 +503,6 @@ void CreateAllHints() {

//get a random hint type from the remaining hints
HintType type = RandomElement(remainingHintTypes, true);

PlacementLog_Msg("Attempting to make hint of type: ");
PlacementLog_Msg(std::to_string(static_cast<int>(type)));
PlacementLog_Msg("\n");
Expand Down Expand Up @@ -519,10 +542,10 @@ void CreateAllHints() {
}

//If any gossip stones failed to have a hint placed on them for some reason, place a junk hint as a failsafe.
/*for (LocationKey gossipStone : FilterFromPool(gossipStoneLocations, [](const LocationKey loc){return Location(loc)->GetPlacedItemKey() == NONE;})) {
for (LocationKey gossipStone : FilterFromPool(gossipStoneLocations, [](const LocationKey loc){return Location(loc)->GetPlacedItemKey() == NONE;})) {
const HintText junkHint = RandomElement(GetHintCategory(HintCategory::Junk));
//AddHint(junkHint.GetText(), gossipStone, {QM_PINK});
}*/
AddHint(junkHint.GetText(), gossipStone, {QM_RED});
}

//Getting gossip stone locations temporarily sets one location to not be reachable.
//Call the function one last time to get rid of false positives on locations not
Expand Down
1 change: 1 addition & 0 deletions source/include/hints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <vector>

#include "keys.hpp"
#include "text.hpp"
#include "random.hpp"
#include "settings.hpp"
Expand Down
4 changes: 4 additions & 0 deletions source/include/item_location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ class ItemLocation {
return scene;
}

u16 GetTextID() const {
return textID;
}

u8 GetFlag() const {
return flag;
}
Expand Down
2 changes: 1 addition & 1 deletion source/include/keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ typedef enum {
JUNK68,
JUNK69,
JUNK70,
JUMK71,
JUNK71,
JUNK72,
JUNK73,
JUNK74,
Expand Down
2 changes: 1 addition & 1 deletion source/include/version.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#define RANDOMIZER_VERSION "v1.0Beta"
#define RANDOMIZER_VERSION "v1.0"
#define COMMIT_NUMBER "develop"
Loading

0 comments on commit 71eafc2

Please sign in to comment.