Merge branch 'rando-next' of https://github.com/HarbourMasters/Shipwright into scrubsanity

This commit is contained in:
Garrett Cox 2022-08-23 19:42:15 -05:00
commit 31e8896856
7 changed files with 56 additions and 15 deletions

View file

@ -454,6 +454,7 @@ u32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx);
s8 func_8002F368(GlobalContext* globalCtx); s8 func_8002F368(GlobalContext* globalCtx);
void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y); void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y);
u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx); u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx);
// TODO: Rename the follwing 3 functions using whatever scheme we use when we rename func_8002F434 and func_8002F554.
s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry); s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry);
s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange); s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange);
void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry); void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry);

View file

@ -47,7 +47,7 @@ void CustomMessageManager::ReplaceColors(std::string& string) {
} }
} }
void CustomMessageManager::FormatCustomMessage(std::string& message, uint16_t iid) { void CustomMessageManager::FormatCustomMessage(std::string& message, ItemID iid) {
message.insert(0, ITEM_OBTAINED(iid)); message.insert(0, ITEM_OBTAINED(iid));
size_t start_pos = 0; size_t start_pos = 0;
std::replace(message.begin(), message.end(), '&', NEWLINE()[0]); std::replace(message.begin(), message.end(), '&', NEWLINE()[0]);
@ -81,7 +81,7 @@ bool CustomMessageManager::InsertCustomMessage(std::string tableID, uint16_t tex
return messageInsertResult.second; return messageInsertResult.second;
} }
bool CustomMessageManager::CreateGetItemMessage(std::string tableID, uint16_t giid, uint16_t iid, bool CustomMessageManager::CreateGetItemMessage(std::string tableID, uint16_t giid, ItemID iid,
CustomMessageEntry messageEntry) { CustomMessageEntry messageEntry) {
FormatCustomMessage(messageEntry.english, iid); FormatCustomMessage(messageEntry.english, iid);
FormatCustomMessage(messageEntry.german, iid); FormatCustomMessage(messageEntry.german, iid);

View file

@ -89,7 +89,7 @@ class CustomMessageManager {
with the provided giid (getItemID) as its key. This function also inserts the icon corresponding to with the provided giid (getItemID) as its key. This function also inserts the icon corresponding to
the provided iid (itemID) at the beginning of each page of the textbox. the provided iid (itemID) at the beginning of each page of the textbox.
*/ */
bool CreateGetItemMessage(std::string tableID, uint16_t giid, uint16_t iid, CustomMessageEntry messages); bool CreateGetItemMessage(std::string tableID, uint16_t giid, ItemID iid, CustomMessageEntry messages);
/* /*
Formats the provided Custom Message Entry and inserts it into the table with the provided tableID, Formats the provided Custom Message Entry and inserts it into the table with the provided tableID,
@ -122,7 +122,7 @@ class CustomMessageManager {
& for newline, ^ for wait-for-input, and @ for the player name, & for newline, ^ for wait-for-input, and @ for the player name,
as well as %<letter> for colors (i.e. %r for red and %w for white). as well as %<letter> for colors (i.e. %r for red and %w for white).
*/ */
void FormatCustomMessage(std::string& message, uint16_t iid); void FormatCustomMessage(std::string& message, ItemID iid);
/* /*
Replaces special characters and certain symbols with control codes Replaces special characters and certain symbols with control codes

View file

@ -18,7 +18,7 @@ typedef enum {
typedef struct { typedef struct {
u16 giid; u16 giid;
u16 iid; ItemID iid;
std::string english; std::string english;
std::string german; std::string german;
std::string french; std::string french;

View file

@ -911,15 +911,19 @@ void DrawFlagsTab() {
setMask <<= 1; setMask <<= 1;
} }
static bool keepGsCountUpdated = true; // If playing a Randomizer Save with Shuffle Skull Tokens on anything other than "Off" we don't want to keep
ImGui::Checkbox("Keep GS Count Updated", &keepGsCountUpdated); // GS Token Count updated, since Gold Skulltulas killed will not correlate to GS Tokens Collected.
InsertHelpHoverText("Automatically adjust the number of gold skulltula tokens acquired based on set flags"); if (!(gSaveContext.n64ddFlag && OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_SHUFFLE_TOKENS))) {
int32_t gsCount = 0; static bool keepGsCountUpdated = true;
if (keepGsCountUpdated) { ImGui::Checkbox("Keep GS Count Updated", &keepGsCountUpdated);
for (int32_t gsFlagIndex = 0; gsFlagIndex < 6; gsFlagIndex++) { InsertHelpHoverText("Automatically adjust the number of gold skulltula tokens acquired based on set flags.");
gsCount += std::popcount(static_cast<uint32_t>(gSaveContext.gsFlags[gsFlagIndex])); int32_t gsCount = 0;
if (keepGsCountUpdated) {
for (int32_t gsFlagIndex = 0; gsFlagIndex < 6; gsFlagIndex++) {
gsCount += std::popcount(static_cast<uint32_t>(gSaveContext.gsFlags[gsFlagIndex]));
}
gSaveContext.inventory.gsTokens = gsCount;
} }
gSaveContext.inventory.gsTokens = gsCount;
} }
}); });

View file

@ -1955,6 +1955,15 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) {
} }
} }
/**
* Uses the given `GetItemEntry` to prepare the player to receive an item via the animation
* where Link holds an item over his head. This function does not require an actor for giving
* the player an item, instead setting the player as their own interactRangeActor and getItemDirection.
*
* \param globalCtx the Global Context
* \param getItemEntry the GetItemEntry for the item you want the player to receive.
* \return true if the player can receive an item, false if not.
*/
s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry) { s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry) {
Player* player = GET_PLAYER(globalCtx); Player* player = GET_PLAYER(globalCtx);
@ -1979,6 +1988,22 @@ s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntr
return false; return false;
} }
/**
* Uses the given `GetItemEntry` to prepare the player to receive an item via the animation
* where Link holds an item over his head. This uses data from the actor link is receiving
* the item from to set the player's interactRangeActor and getItemDirection. It also checks
* a range from which Link must be from said actor in order to receive the item.
*
* \param actor the actor link is receiving an item from. Will usually be a chest but can also
* be an npc.
* \param globalCtx the Global Context
* \param getItemEntry the GetItemEntry for the item you want the player to receive.
* \param xzRange the distance on the x and z axes that the player can be from the target
* actor to receive the item.
* \param yRange the distance on the y axis that the player can be from the target actor
* to receive the item.
* \return true if the player can receive an item, false if not.
*/
s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) {
Player* player = GET_PLAYER(globalCtx); Player* player = GET_PLAYER(globalCtx);
@ -2005,6 +2030,15 @@ s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry
return false; return false;
} }
/**
* Uses the given `GetItemEntry` to prepare the player to receive an item via the animation
* where Link holds an item over his head. This is a wrapper function around `GiveItemEntryFromActor`
* that supplies a fixed xzRange of 50.0f and a fixed yRange of 10.0f.
*
* \param actor the target actor that link is receiving an item from.
* \param globalCtx the Global Context
* \param getItemEntry the GetItemEntry for the item you want the player to receive.
*/
void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry) { void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry) {
GiveItemEntryFromActor(actor, globalCtx, getItemEntry, 50.0f, 10.0f); GiveItemEntryFromActor(actor, globalCtx, getItemEntry, 50.0f, 10.0f);
} }

View file

@ -510,8 +510,10 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
} }
if (!Actor_HasParent(&this->actor, globalCtx)) { if (!Actor_HasParent(&this->actor, globalCtx)) {
if (!gSaveContext.n64ddFlag && getItemId != GI_NONE) { if (!gSaveContext.n64ddFlag) {
func_8002F554(&this->actor, globalCtx, getItemId); if (getItemId != GI_NONE) {
func_8002F554(&this->actor, globalCtx, getItemId);
}
} else { } else {
getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum); getItem = Randomizer_GetRandomizedItem(getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum);
GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem); GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, getItem);