Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions soh/assets/custom/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,20 @@
"rocs_feather": {
"name": "Roc's Feather",
"description": [
"Adds Roc's Feather to the item pool. Roc's Feather is a custom item granting the player a jump on demand. ",
"The jump can also be used when already in mid-air. Roc's Feather is not considered by logic."
"Off - Roc's Feather will not be shuffled. No changes will be made to the item pool.\n\n",
"On - Adds Roc's Feather to the item pool. Roc's Feather is a custom item granting the ",
"player a jump on demand. Increasing Quantity will allow an additional, consecutive ",
"jump with each feather found.\n\n",
"Consumable - Adds a variable number of consumable Roc's Feathers to the item pool, matching ",
"Max Capacity at an absolute minimum.\n\n",
"Roc's Feather is not considered by logic."
]
},
"rocs_feather_count": {
"name": "Roc's Feather Quantity / Max Capacity",
"description": [
"If Roc's Feather is 'On' this will be the number of feathers obtainable in the pool. ",
"If Roc's Feather is 'Consumable' this will be the maximum you can carry at once."
]
},
"nayrus_love_uses": {
Expand Down
2 changes: 2 additions & 0 deletions soh/include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ typedef struct ShipRandomizerSaveContextData {
s8 silverMqSpiritBigWall;
s8 silverMqGanonWater;
s8 silverMqGanonShadow;
u8 rocsFeathersAcquired;
u8 rocsFeathersRemaining;
Comment thread
horrible marked this conversation as resolved.
Resolved
} ShipRandomizerSaveContextData;

typedef struct ShipBossRushSaveContextData {
Expand Down
13 changes: 11 additions & 2 deletions soh/soh/Enhancements/randomizer/3drando/item_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,17 @@ void GenerateItemPool() {
if (!ctx->GetOption(RSK_STARTING_MASK_OF_TRUTH)) AddItemToPool(RG_MASK_OF_TRUTH, 2, 1, 1, 1);
}

if (ctx->GetOption(RSK_ROCS_FEATHER)) {
AddItemToPool(RG_ROCS_FEATHER, 2, 1, 1, 1);
if (!ctx->GetOption(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_OFF)) {
int feathers = ctx->GetOption(RSK_ROCS_FEATHER_COUNT).Get() + 1;
if (ctx->GetOption(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_ON)) {
AddFixedItemToPool(RG_ROCS_FEATHER, feathers);
} else {
//ensure at least one full fill of feathers
AddFixedItemToPool(RG_ROCS_FEATHER, feathers);
//include in the junk pool for additional acq
JunkPoolItems.emplace_back(RG_ROCS_FEATHER);
JunkPoolItems.emplace_back(RG_ROCS_FEATHER);
}
}

int bronzeScale = ctx->GetOption(RSK_SHUFFLE_SWIM) ? 1 : 0;
Expand Down
21 changes: 20 additions & 1 deletion soh/soh/Enhancements/randomizer/Messages/ItemMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ void BuildTriforceMessage(CustomMessage& msg) {
msg.Format(ITEM_CUSTOM);
}

void BuildRocsFeatherMessage(CustomMessage& msg) {
u8 max = (Rando::Context::GetInstance()->GetOption(RSK_ROCS_FEATHER_COUNT).Get() + 1);
bool consumable = Rando::Context::GetInstance()->GetOption(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_CONSUMABLE);
u8& current = gSaveContext.ship.quest.data.randomizer.rocsFeathersRemaining;
u8& total = gSaveContext.ship.quest.data.randomizer.rocsFeathersAcquired;
msg = CustomMessage("You got %bRoc's Feather%w!&You now have %b[[d]]%w |use|uses| of it!",
"Du erhältst %bGreifenfeder%w!&Du kannst sie nun %b[[d]]%w-mal einsetzen!",
"Vous obtenez la %bPlume de Roc%w!&Vous pouvez l'utiliser %b[[d]]%w fois!");

if (consumable) {
msg.InsertNumber(current < max ? current + 1 : current);
} else {
msg.InsertNumber(total < max ? total + 1 : total);
}
msg.AutoFormat(ITEM_ROCS_FEATHER);
}

void BuildCustomItemMessage(Player* player, CustomMessage& msg) {
int16_t rgid;
msg = CustomMessage("You found [[article]][[color]][[name]]%w!", "Du hast [[article]][[color]][[name]]%w gefunden!",
Expand Down Expand Up @@ -258,6 +275,8 @@ void BuildItemMessage(u16* textId, bool* loadFromMessageTable) {
BuildTriforcePieceMessage(msg);
} else if (player->getItemEntry.getItemId == RG_TRIFORCE) {
BuildTriforceMessage(msg);
} else if (player->getItemEntry.getItemId == RG_ROCS_FEATHER) {
BuildRocsFeatherMessage(msg);
} else {
BuildCustomItemMessage(player, msg);
}
Expand Down Expand Up @@ -384,4 +403,4 @@ void RegisterCustomIconHooks() {
});
}

static RegisterShipInitFunc customIconInitFunc(RegisterCustomIconHooks, { "IS_RANDO" });
static RegisterShipInitFunc customIconInitFunc(RegisterCustomIconHooks, { "IS_RANDO" });
96 changes: 58 additions & 38 deletions soh/soh/Enhancements/randomizer/RocsFeather.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <libultraship/bridge/consolevariablebridge.h>

#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/randomizer/SeedContext.h"
#include "soh/ShipInit.hpp"

extern "C" {
Expand All @@ -8,19 +11,67 @@ extern "C" {
#include "variables.h"
#include "macros.h"
extern PlayState* gPlayState;
extern SaveContext gSaveContext;
}

#define MAX_ROCS_USES 1

static uint8_t rocsUseCount = 0;
static uint8_t groundTimer = 0;
static f32 effectsScale = 1.0f;
static bool rocsConsumable = true;

static u8& RocsFeathersAcquired() {
return gSaveContext.ship.quest.data.randomizer.rocsFeathersAcquired;
}

static u8& RocsFeathersRemaining() {
return gSaveContext.ship.quest.data.randomizer.rocsFeathersRemaining;
}

void UseRocsFeather(PlayState* playState, Player* player) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a message builder here to keep a consistent experience with consumable Nayru's

This comment was marked as outdated.

if (RocsFeathersRemaining() > 0) {
RocsFeathersRemaining()--;

func_80838940(player, (LinkAnimationHeader*)&gPlayerAnim_link_rocs_feather_jump, 5.8f, playState, 0);

// Actionvar needed to prevent weird animation morph
player->av2.actionVar2 = 1;

// Move player forward on Roc's use
player->linearVelocity = 5.0f;
player->actor.world.rot.y = player->yaw = player->actor.shape.rot.y;

if (gSaveContext.linkAge == LINK_AGE_CHILD) {
player->actor.velocity.y = 7.0f;
effectsScale = 1.0f;
} else {
player->actor.velocity.y = 7.5f;
effectsScale = 1.5f;
}

Vec3f effectsPos = player->actor.home.pos;
effectsPos.y += 3;

EffectSsGRipple_Spawn(playState, &effectsPos, static_cast<s16>(200 * effectsScale),
static_cast<s16>(300 * effectsScale), 1);
EffectSsGSplash_Spawn(playState, &effectsPos, NULL, NULL, 0, static_cast<s16>(150 * effectsScale));

// Remove hopping state when using Roc's after sidehop/backflip to allow grabbing ledges again
player->stateFlags2 &= ~(PLAYER_STATE2_HOPPING);

Player_PlaySfx(&player->actor, NA_SE_PL_SKIP);
} else {
Sfx_PlaySfxCentered(NA_SE_SY_ERROR);
}
}

void RegisterRocsFeather() {
// Always register hooks - they only activate when ITEM_ROCS_FEATHER is actually used
// Rando-specific logic (item pool, accessibility, etc.) is handled elsewhere
bool shouldRegister = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for @serprex - I realize this is inherited but wondering if registration should at least be gated on IS_RANDO and a CVar?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I think there was some effort made to allow enabling Roc's Feather in normal play using save editor. I don't think maintaining that is necessary if this can be made more elegant by not supporting that


COND_HOOK(OnLoadFile, shouldRegister, [](int32_t fileNum) {
rocsConsumable = Rando::Context::GetInstance()->GetOption(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_CONSUMABLE);
});

COND_HOOK(OnPlayerUpdate, shouldRegister, []() {
Player* player = GET_PLAYER(gPlayState);

Expand All @@ -33,8 +84,8 @@ void RegisterRocsFeather() {
groundTimer = 0;
}

if (groundTimer >= 3) {
rocsUseCount = 0;
if (!rocsConsumable && groundTimer >= 3) {
RocsFeathersRemaining() = RocsFeathersAcquired();
}
});

Expand All @@ -45,40 +96,9 @@ void RegisterRocsFeather() {
if (usedItem == ITEM_ROCS_FEATHER) {
*should = false;

if (rocsUseCount < MAX_ROCS_USES) {
rocsUseCount++;

Player* player = GET_PLAYER(gPlayState);

func_80838940(player, (LinkAnimationHeader*)&gPlayerAnim_link_rocs_feather_jump, 5.8f, gPlayState, 0);
Player* player = GET_PLAYER(gPlayState);

// Actionvar needed to prevent weird animation morph
player->av2.actionVar2 = 1;

// Move player forward on Roc's use
player->linearVelocity = 5.0f;
player->actor.world.rot.y = player->yaw = player->actor.shape.rot.y;

if (gSaveContext.linkAge == LINK_AGE_CHILD) {
player->actor.velocity.y = 7.0f;
effectsScale = 1.0f;
} else {
player->actor.velocity.y = 7.5f;
effectsScale = 1.5f;
}

Vec3f effectsPos = player->actor.home.pos;
effectsPos.y += 3;

EffectSsGRipple_Spawn(gPlayState, &effectsPos, static_cast<s16>(200 * effectsScale),
static_cast<s16>(300 * effectsScale), 1);
EffectSsGSplash_Spawn(gPlayState, &effectsPos, NULL, NULL, 0, static_cast<s16>(150 * effectsScale));

// Remove hopping state when using Roc's after sidehop/backflip to allow grabbing ledges again
player->stateFlags2 &= ~(PLAYER_STATE2_HOPPING);

Player_PlaySfx(&player->actor, NA_SE_PL_SKIP);
}
UseRocsFeather(gPlayState, player);
}
});

Expand Down
18 changes: 17 additions & 1 deletion soh/soh/Enhancements/randomizer/SeedContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,22 @@ void Context::HandleGetBombchuBag() {
return;
}
}
void Context::HandleGetRocsFeather() {
Flags_SetRandomizerInf(RAND_INF_OBTAINED_ROCS_FEATHER);

bool rocsConsumable = Rando::Context::GetInstance()->GetOption(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_CONSUMABLE);
uint8_t rocsMaxUse = Rando::Context::GetInstance()->GetOption(RSK_ROCS_FEATHER_COUNT).Get() + 1;
uint8_t& rocsRemaining = mLogic->GetSaveContext()->ship.quest.data.randomizer.rocsFeathersRemaining;
uint8_t& rocsAcquired = mLogic->GetSaveContext()->ship.quest.data.randomizer.rocsFeathersAcquired;

if (!rocsConsumable) {
rocsAcquired = rocsAcquired < rocsMaxUse ? rocsAcquired + 1 : rocsMaxUse;
rocsRemaining = rocsAcquired;
} else {
rocsAcquired = rocsMaxUse;
rocsRemaining = rocsRemaining < rocsAcquired ? rocsRemaining + 1 : rocsAcquired;
}
}

const std::string& Context::GetSeedString() const {
return mSeedString;
Expand All @@ -648,4 +664,4 @@ uint32_t Context::GetSeed() const {
void Context::SetSeed(const uint32_t seed) {
mFinalSeed = seed;
}
} // namespace Rando
} // namespace Rando
3 changes: 2 additions & 1 deletion soh/soh/Enhancements/randomizer/SeedContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class Context {
void SetHash(std::string hash);
uint8_t GetBombchuCapacity();
void HandleGetBombchuBag();
void HandleGetRocsFeather();

private:
static std::weak_ptr<Context> mContext;
Expand All @@ -200,4 +201,4 @@ class Context {
std::string mSeedString;
uint32_t mFinalSeed = 0;
};
} // namespace Rando
} // namespace Rando
25 changes: 25 additions & 0 deletions soh/soh/Enhancements/randomizer/hook_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,31 @@ void RandomizerOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_l
}
if (item == ITEM_NAYRUS_LOVE) {
*should = RAND_GET_OPTION(RSK_NAYRUS_LOVE_USES).Get() > 0;
} else if (item == ITEM_ROCS_FEATHER) {
*should = RAND_GET_OPTION(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_CONSUMABLE) ||
gSaveContext.ship.quest.data.randomizer.rocsFeathersAcquired != 1;
}
break;
}
case VB_OVERRIDE_AMMO_COUNT: {
s16 item = *va_arg(args, s16*);
s16* ammo = va_arg(args, s16*);
if (item == ITEM_ROCS_FEATHER) {
if (RAND_GET_OPTION(RSK_ROCS_FEATHER).Is(RO_ROCS_FEATHER_CONSUMABLE) ||
gSaveContext.ship.quest.data.randomizer.rocsFeathersAcquired != 1) {
*should = false;
*ammo = gSaveContext.ship.quest.data.randomizer.rocsFeathersRemaining;
} else {
*should = true;
}
}
break;
}
case VB_COLOR_AMMO_GREEN: {
int item = va_arg(args, int);
if (item == ITEM_ROCS_FEATHER) {
*should = gSaveContext.ship.quest.data.randomizer.rocsFeathersAcquired ==
gSaveContext.ship.quest.data.randomizer.rocsFeathersRemaining;
}
break;
}
Expand Down
4 changes: 3 additions & 1 deletion soh/soh/Enhancements/randomizer/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,6 @@ static constexpr std::pair<RandomizerGet, uint32_t> randInfTable[] = {
{ RG_SPEAK_ZORA, RAND_INF_CAN_SPEAK_ZORA },
{ RG_FISHING_POLE, RAND_INF_FISHING_POLE_FOUND },
{ RG_SCARECROWS_SONG, RAND_INF_HAS_SCARECROWS_SONG },
{ RG_ROCS_FEATHER, RAND_INF_OBTAINED_ROCS_FEATHER },
{ RG_GUARD_HOUSE_KEY, RAND_INF_GUARD_HOUSE_KEY_OBTAINED },
{ RG_MARKET_BAZAAR_KEY, RAND_INF_MARKET_BAZAAR_KEY_OBTAINED },
{ RG_MARKET_POTION_SHOP_KEY, RAND_INF_MARKET_POTION_SHOP_KEY_OBTAINED },
Expand Down Expand Up @@ -2640,6 +2639,9 @@ void Logic::ApplyItemEffect(Item& item, bool state) {
SetInventory(ITEM_BOMBCHU, (!state ? ITEM_NONE : ITEM_BOMBCHU));
}
break;
case RG_ROCS_FEATHER:
OTRGlobals::Instance->gRandoContext->HandleGetRocsFeather();
break;
default:
break;
}
Expand Down
10 changes: 6 additions & 4 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,6 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
if (!ChildTradeSlotOccupied()) {
INV_CONTENT(ITEM_TRADE_CHILD) = ITEM_LETTER_ZELDA;
}
} else if (item == RG_ROCS_FEATHER) {
if (INV_CONTENT(ITEM_NAYRUS_LOVE) == ITEM_NONE) {
INV_CONTENT(ITEM_NAYRUS_LOVE) = ITEM_ROCS_FEATHER;
}
} else if (item == RG_CHILD_WALLET &&
OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_FULL_WALLETS)) {
Rupees_ChangeBy(99);
Expand Down Expand Up @@ -1417,6 +1413,12 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
INV_CONTENT(ITEM_NUT) = ITEM_NUT;
AMMO(ITEM_NUT) = static_cast<int8_t>(CUR_CAPACITY(UPG_NUTS));
break;
case RG_ROCS_FEATHER:
if (INV_CONTENT(ITEM_NAYRUS_LOVE) == ITEM_NONE) {
INV_CONTENT(ITEM_NAYRUS_LOVE) = ITEM_ROCS_FEATHER;
}
OTRGlobals::Instance->gRandoContext->HandleGetRocsFeather();
break;
case RG_SHADOW_SILVER_BLADES:
case RG_SHADOW_SILVER_PIT:
case RG_SHADOW_SILVER_SPIKES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ RANDO_ENUM_ITEM(RO_SCRUBS_ONE_TIME_ONLY)
RANDO_ENUM_ITEM(RO_SCRUBS_ALL)
RANDO_ENUM_END(RandoOptionScrubsanity)

// Roc's Feather settings (off, permanent, consumable)
RANDO_ENUM_BEGIN(RandoOptionRocsFeather)
RANDO_ENUM_ITEM(RO_ROCS_FEATHER_OFF)
RANDO_ENUM_ITEM(RO_ROCS_FEATHER_ON)
RANDO_ENUM_ITEM(RO_ROCS_FEATHER_CONSUMABLE)
RANDO_ENUM_END(RandoOptionRocsFeather)

// Ammo drop settings (on, "on+bombchu", off)
RANDO_ENUM_BEGIN(RandoOptionAmmoDrops)
RANDO_ENUM_ITEM(RO_AMMO_DROPS_OFF)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ RANDO_ENUM_ITEM(RSK_STARTING_GERUDO_MASK)
RANDO_ENUM_ITEM(RSK_STARTING_MASK_OF_TRUTH)
RANDO_ENUM_ITEM(RSK_PROGRESSIVE_GORON_SWORD)
RANDO_ENUM_ITEM(RSK_NAYRUS_LOVE_USES)
RANDO_ENUM_ITEM(RSK_ROCS_FEATHER_COUNT)
RANDO_ENUM_ITEM(RSK_MAX)
RANDO_ENUM_END(RandomizerSettingKey)

Expand Down
Loading