Skip to content

Commit

Permalink
Merge branch 'develop' of garrettjoecox.github.com:HarbourMasters/2sh…
Browse files Browse the repository at this point in the history
…ip2harkinian into develop-rando
  • Loading branch information
garrettjoecox committed Feb 1, 2025
2 parents 106d585 + f8d6afe commit 60c519e
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 24 deletions.
19 changes: 17 additions & 2 deletions mm/2s2h/BenGui/BenMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,9 @@ void BenMenu::AddEnhancements() {
AddWidget(path, "Faster Song Playback", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Songs.FasterSongPlayback")
.Options(CheckboxOptions().Tooltip("Speeds up the playback of songs."));
AddWidget(path, "Skip Song of Time cutscenes", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Songs.SkipSoTCutscenes")
.Options(CheckboxOptions().Tooltip("Skips the cutscenes when playing any of the Song of Time songs"));

// Time Savers
path = { "Enhancements", "Time Savers", 1 };
Expand Down Expand Up @@ -1250,12 +1253,12 @@ void BenMenu::AddEnhancements() {
path = { "Enhancements", "Difficulty Options", 1 };
AddSidebarEntry("Enhancements", "Difficulty Options", 3);
AddWidget(path, "Disable Takkuri Steal", WIDGET_CVAR_CHECKBOX)
.CVar("gEnhancements.Cheats.DisableTakkuriSteal")
.CVar("gEnhancements.DifficultyOptions.DisableTakkuriSteal")
.Options(CheckboxOptions().Tooltip(
"Prevents the Takkuri from stealing key items like bottles and swords. It may still steal "
"other items."));
AddWidget(path, "Deku Guard Search Balls", WIDGET_CVAR_COMBOBOX)
.CVar("gEnhancements.Cheats.DekuGuardSearchBalls")
.CVar("gEnhancements.DifficultyOptions.DekuGuardSearchBalls")
.Options(
ComboboxOptions()
.Tooltip("Choose when to show the Deku Palace Guards' search balls\n"
Expand All @@ -1270,6 +1273,18 @@ void BenMenu::AddEnhancements() {
CheckboxOptions().Tooltip("Reduces the amount of rupees required to receive the rewards from the bank.\n"
"From: 200 -> 1000 -> 5000\n"
"To: 100 -> 500 -> 1000"));
AddWidget(path, "Gibdo Trade Sequence Options", WIDGET_CVAR_COMBOBOX)
.CVar("gEnhancements.DifficultyOptions.GibdoTradeSequence")
.Options(
ComboboxOptions()
.Tooltip(
"Changes the way the Gibdo Trade Sequence works\n"
"-Vanilla: Works normally\n"
"-MM3D: Gibdos will only take one quantity of the item they request, as they do in MM3D. The Gibdo "
"requesting a blue potion will also accept a red potion.\n"
"-No trade: Gibdos will vanish without taking items")
.DefaultIndex(GibdoTradeSequenceOptions::GIBDO_TRADE_SEQUENCE_VANILLA)
.ComboMap(gibdoTradeSequenceOptions));

path.column = 2;
AddWidget(path, "Damage Multiplier", WIDGET_CVAR_COMBOBOX)
Expand Down
6 changes: 6 additions & 0 deletions mm/2s2h/BenGui/BenMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ static const std::unordered_map<int32_t, const char*> cremiaRewardOptions = {
{ CREMIA_REWARD_ALWAYS_RUPEE, "Rupee" },
};

static const std::unordered_map<int32_t, const char*> gibdoTradeSequenceOptions = {
{ GIBDO_TRADE_SEQUENCE_VANILLA, "Vanilla" },
{ GIBDO_TRADE_SEQUENCE_MM3D, "MM3D" },
{ GIBDO_TRADE_SEQUENCE_NO_TRADE, "No trade" },
};

static const std::unordered_map<int32_t, const char*> clockTypeOptions = {
{ CLOCK_TYPE_ORIGINAL, "Original" },
{ CLOCK_TYPE_3DS, "MM3D style" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Enhancements/Enhancements.h"
#include "2s2h/ShipInit.hpp"

#define CVAR_NAME "gEnhancements.Cheats.DekuGuardSearchBalls"
#define CVAR_NAME "gEnhancements.DifficultyOptions.DekuGuardSearchBalls"
#define CVAR CVarGetInteger(CVAR_NAME, DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY)

void RegisterShowDekuGuardSearchBalls() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

#define CVAR_NAME "gEnhancements.Cheats.DisableTakkuriSteal"
#define CVAR_NAME "gEnhancements.DifficultyOptions.DisableTakkuriSteal"
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterDisableTakkuriSteal() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/Enhancements/Enhancements.h"
#include "2s2h/ShipInit.hpp"
#include <stdarg.h>

#define CVAR_NAME "gEnhancements.DifficultyOptions.GibdoTradeSequence"
#define CVAR CVarGetInteger(CVAR_NAME, GIBDO_TRADE_SEQUENCE_VANILLA)

extern "C" {
#include "functions.h"
#include "variables.h"
#include "overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h"

// redefinition
typedef struct {
/* 0x0 */ PlayerItemAction itemAction;
/* 0x4 */ ItemId item;
/* 0x8 */ s32 amount;
/* 0xC */ s16 isBottledItem;
} EnTalkGibudRequestedItem; // size = 0x10
}

static EnTalkGibudRequestedItem redPotionRequestedItem = { PLAYER_IA_BOTTLE_POTION_RED, ITEM_POTION_RED, 1, true };

void RegisterGibdoTradeSequenceOptions() {
COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_SUFFICIENT_QUANTITY_PRESENTED, CVAR != GIBDO_TRADE_SEQUENCE_VANILLA, {
ItemId requestedItemId = (ItemId)va_arg(args, int);
if (AMMO(requestedItemId) >= 1) {
*should = true;
}
});

COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_ACCEPT_RED_POTION, CVAR == GIBDO_TRADE_SEQUENCE_MM3D, {
PlayerItemAction requestedItemAction = (PlayerItemAction)va_arg(args, int);
PlayerItemAction presentedItemAction = (PlayerItemAction)va_arg(args, int);

EnTalkGibudRequestedItem** requestedItem = va_arg(args, EnTalkGibudRequestedItem**);

if (requestedItemAction == PLAYER_IA_BOTTLE_POTION_BLUE &&
presentedItemAction ==
PLAYER_IA_BOTTLE_POTION_RED) { // If requested blue potion, but presented red potion, switch out
// requested item from blue potion to red potion.
*should = true;
*requestedItem = &redPotionRequestedItem;
}
});

COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_TAKE_MORE_THAN_ONE_ITEM, CVAR != GIBDO_TRADE_SEQUENCE_VANILLA, {
*should = false;

EnTalkGibudRequestedItem* requestedItem = va_arg(args, EnTalkGibudRequestedItem*);
if (CVAR == GIBDO_TRADE_SEQUENCE_MM3D) {
Inventory_ChangeAmmo(requestedItem->item, -1);
}
});

COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_DO_TRADE, CVAR == GIBDO_TRADE_SEQUENCE_NO_TRADE, {
*should = false;

EnTalkGibud* gibudCtx = va_arg(args, EnTalkGibud*);
bool doEndTradeMessage = va_arg(args, bool);

if (doEndTradeMessage) {
Message_StartTextbox(gPlayState, 0x138A, &gibudCtx->actor);
gibudCtx->textId = 0x138A;
}
});
}

static RegisterShipInitFunc initFunc(RegisterGibdoTradeSequenceOptions, { CVAR_NAME });
6 changes: 6 additions & 0 deletions mm/2s2h/Enhancements/Enhancements.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ enum CremiaRewardsOptions {
CREMIA_REWARD_ALWAYS_RUPEE,
};

enum GibdoTradeSequenceOptions {
GIBDO_TRADE_SEQUENCE_VANILLA,
GIBDO_TRADE_SEQUENCE_MM3D,
GIBDO_TRADE_SEQUENCE_NO_TRADE,
};

enum DekuGuardSearchBallsOptions {
DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY,
DEKU_GUARD_SEARCH_BALLS_NEVER,
Expand Down
19 changes: 10 additions & 9 deletions mm/2s2h/Enhancements/Songs/BetterSongOfDoubleTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ void OnPlayerUpdate(Actor* actor) {

gPlayState->nextEntrance = gSaveContext.save.entrance;
gPlayState->transitionTrigger = TRANS_TRIGGER_START;
gPlayState->transitionType = TRANS_TYPE_INSTANT;

gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = gSaveContext.save.entrance;
gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex = gPlayState->roomCtx.curRoom.num;
gSaveContext.respawn[RESPAWN_MODE_DOWN].pos = player->actor.world.pos;
gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw = player->actor.shape.rot.y;
gSaveContext.respawn[RESPAWN_MODE_DOWN].playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D);
gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK_FAST;
gSaveContext.respawnFlag = -8;
gPlayState->transitionType = TRANS_TYPE_FADE_BLACK_FAST;

Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_RETURN, gSaveContext.save.entrance,
gPlayState->roomCtx.curRoom.num, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B),
&player->actor.world.pos, player->actor.world.rot.y);
gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK;
gSaveContext.respawnFlag = 2;

// Stop BGM so that new day sequences can play
gSaveContext.seqId = (u8)NA_BGM_DISABLED;

GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorKill>(onEnTest6KillHookId);
onEnTest6KillHookId = 0;
Expand Down
68 changes: 68 additions & 0 deletions mm/2s2h/Enhancements/Songs/SkipSoTCutscenes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

extern "C" {
#include "variables.h"
#include "overlays/actors/ovl_En_Test6/z_en_test6.h"

void EnTest6_DoubleSoTCutscene(EnTest6* thisx, PlayState* play);
void EnTest6_InvertedSoTCutscene(EnTest6* thisx, PlayState* play);
void EnTest6_StopDoubleSoTCutscene(EnTest6* thisx, PlayState* play);
void EnTest6_StopInvertedSoTCutscene(EnTest6* thisx, PlayState* play);
}

#define CVAR_NAME "gEnhancements.Songs.SkipSoTCutscenes"
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterSkipSoTCutscenes() {
// Song of Time cutscene plays as part of an entrance, so set the time and
// hijack the entrance to the destination
COND_VB_SHOULD(VB_PLAY_TRANSITION_CS, CVAR, {
if ((gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 0) ||
gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 1)) &&
gSaveContext.save.cutsceneIndex == 0xFFF7) {
gSaveContext.save.eventDayCount = 0;
gSaveContext.save.day = 0;
gSaveContext.save.time = CLOCK_TIME(6, 0) - 1;

if (gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 1)) {
// Loads to flash back montage before going to Dawn of... in clock town
// Use ENTRANCE(SOUTH_CLOCK_TOWN, 10) if we ever add a story cutscene skip for the flash backs
gSaveContext.save.entrance = ENTRANCE(LOST_WOODS, 1);
} else {
// Directly to Dawn of... in clock town
gSaveContext.save.entrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0);
}

gSaveContext.save.cutsceneIndex = 0;
}
});

// Skips inverted/double time cutscenes by forcing the actor to stop
COND_ID_HOOK(OnActorUpdate, ACTOR_EN_TEST6, CVAR, [](Actor* actor) {
EnTest6* enTest6 = (EnTest6*)actor;

if (enTest6->actionFunc == EnTest6_DoubleSoTCutscene) {
enTest6->actionFunc = EnTest6_StopDoubleSoTCutscene;
Player* player = GET_PLAYER(gPlayState);

// Respawns the player out when going from day -> night
// copied from last cutscene cue SOTCS_CUEID_DOUBLE_END in EnTest6_SharedSoTCutscene
if (gSaveContext.save.time > CLOCK_TIME(12, 0)) {
Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_RETURN, gSaveContext.save.entrance,
player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0,
player->unk_3CC);
gPlayState->transitionTrigger = TRANS_TRIGGER_START;
gPlayState->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_RETURN].entrance;
gPlayState->transitionType = TRANS_TYPE_FADE_BLACK;
gSaveContext.respawnFlag = 2;
gPlayState->msgCtx.ocarinaMode = OCARINA_MODE_END;
}
} else if (enTest6->actionFunc == EnTest6_InvertedSoTCutscene) {
enTest6->actionFunc = EnTest6_StopInvertedSoTCutscene;
}
});
}

static RegisterShipInitFunc initFunc(RegisterSkipSoTCutscenes, { CVAR_NAME });
4 changes: 4 additions & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ typedef enum {
VB_FISH2_SPAWN_HEART_PIECE,
VB_PLAY_DEFEAT_CAPTAIN_SEQUENCE,
VB_CLAMP_ANIMATION_SPEED,
VB_GIBDO_TRADE_SEQUENCE_SUFFICIENT_QUANTITY_PRESENTED,
VB_GIBDO_TRADE_SEQUENCE_ACCEPT_RED_POTION,
VB_GIBDO_TRADE_SEQUENCE_TAKE_MORE_THAN_ONE_ITEM,
VB_GIBDO_TRADE_SEQUENCE_DO_TRADE,
} GIVanillaBehavior;

typedef enum {
Expand Down
5 changes: 3 additions & 2 deletions mm/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -8425,8 +8425,9 @@ void Interface_Draw(PlayState* play) {
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha);
gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255);

gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24,
24, // 2S2H [Port] This last 24 was 18 in the minibuild, not sure why
// @bug: This texture has a size of 24x18, but the original code reads in 24x24, reading garbage data
// 2S2H [Port] We are opting to fix this by using the correct size
gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 18,
0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);

Expand Down
29 changes: 20 additions & 9 deletions mm/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Overlay: ovl_En_Talk_Gibud
* Description: Gibdos requesting items Beneath the Well
*/

#include "2s2h/GameInteractor/GameInteractor.h"
#include "z_en_talk_gibud.h"
#include "z64rumble.h"

Expand Down Expand Up @@ -713,10 +713,12 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, PlayState* play) {

s32 EnTalkGibud_PresentedItemMatchesRequest(EnTalkGibud* this, PlayState* play, PlayerItemAction presentedItemAction) {
EnTalkGibudRequestedItem* requestedItem = &sRequestedItemTable[this->requestedItemIndex];

GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_ACCEPT_RED_POTION, false, requestedItem->itemAction,
presentedItemAction, &requestedItem);
if (requestedItem->itemAction == presentedItemAction) {
if (!requestedItem->isBottledItem) {
if (AMMO(requestedItem->item) >= requestedItem->amount) {
if (GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_SUFFICIENT_QUANTITY_PRESENTED,
AMMO(requestedItem->item) >= requestedItem->amount, requestedItem->item)) {
return EN_TALK_GIBUD_REQUESTED_ITEM_MET;
} else {
return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO;
Expand Down Expand Up @@ -782,8 +784,10 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) {
void EnTalkGibud_PassiveIdle(EnTalkGibud* this, PlayState* play) {
if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
this->isTalking = true;
Message_StartTextbox(play, 0x1388, &this->actor);
this->textId = 0x1388;
if (GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_DO_TRADE, true, this, true)) {
Message_StartTextbox(play, 0x1388, &this->actor);
this->textId = 0x1388;
}
Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_AIM);
EnTalkGibud_SetupTalk(this);
} else if (this->actor.xzDistToPlayer < 100.0f && !(this->collider.base.acFlags & AC_HIT)) {
Expand Down Expand Up @@ -828,10 +832,17 @@ void EnTalkGibud_Talk(EnTalkGibud* this, PlayState* play) {
if (this->textId == 0x138A) {
// Remove the requested item/amount from the player's inventory
requestedItem = &sRequestedItemTable[this->requestedItemIndex];
if (!requestedItem->isBottledItem) {
Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount);
} else {
Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY);
if (GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_DO_TRADE, true, this,
false)) { // We don't want to try to change their inventory if they don't
// need to trade anything
if (!requestedItem->isBottledItem) {
if (GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_TAKE_MORE_THAN_ONE_ITEM, true,
requestedItem)) {
Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount);
}
} else {
Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY);
}
}
player->stateFlags1 |= PLAYER_STATE1_20;
player->stateFlags1 |= PLAYER_STATE1_20000000;
Expand Down

0 comments on commit 60c519e

Please sign in to comment.