Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add Gibdo Trade Sequence Options #917

Merged
12 changes: 12 additions & 0 deletions mm/2s2h/BenGui/BenMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,18 @@ void BenMenu::AddEnhancements() {
"- Always: Always show the search balls.")
.DefaultIndex(DekuGuardSearchBallsOptions::DEKU_GUARD_SEARCH_BALLS_NIGHT_ONLY)
.ComboMap(dekuGuardSearchBallsOptions));
AddWidget(path, "Gibdo Trade Sequence Options", WIDGET_CVAR_COMBOBOX)
.CVar("gEnhancements.Cheats.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
@@ -0,0 +1,37 @@
#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.Cheats.GibdoTradeSequence"
#define CVAR CVarGetInteger(CVAR_NAME, GIBDO_TRADE_SEQUENCE_VANILLA)

extern "C" {
#include "functions.h"
#include "variables.h"
}

void RegisterGibdoTradeSequenceOptions() {
COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_SUFFICIENT_QUANTITY_PRESENTED, CVAR != GIBDO_TRADE_SEQUENCE_VANILLA, {
ItemId requestedItemId = va_arg(args, ItemId);
zodiac-ill marked this conversation as resolved.
Show resolved Hide resolved
if (AMMO(requestedItemId) >= 1) {
*should = true;
}
});

COND_VB_SHOULD(VB_GIBDO_TRADE_SEQUENCE_ACCEPT_RED_POTION, CVAR == GIBDO_TRADE_SEQUENCE_MM3D, {
PlayerItemAction requestedItemAction = va_arg(args, PlayerItemAction);
PlayerItemAction presentedItemAction = va_arg(args, PlayerItemAction);
zodiac-ill marked this conversation as resolved.
Show resolved Hide resolved

*should = (requestedItemAction == PLAYER_IA_BOTTLE_POTION_BLUE) &&
(presentedItemAction == PLAYER_IA_BOTTLE_POTION_RED);
});

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

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

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
4 changes: 4 additions & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ typedef enum {
VB_GORON_ROLL_DISABLE_SPIKE_MODE,
VB_DEKU_LINK_SPIN_ON_LAST_HOP,
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
41 changes: 31 additions & 10 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 @@ -71,7 +71,8 @@ typedef enum {
/* 6 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS,
/* 7 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER,
/* 8 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE,
/* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK
/* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK,
/* 10 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_POTION_RED,
} EnTalkGibudRequestedItemIndex;

typedef enum {
Expand Down Expand Up @@ -210,6 +211,7 @@ static EnTalkGibudRequestedItem sRequestedItemTable[] = {
{ PLAYER_IA_BOTTLE_HOT_SPRING_WATER, ITEM_HOT_SPRING_WATER, 1, true },
{ PLAYER_IA_BOTTLE_BIG_POE, ITEM_BIG_POE, 1, true },
{ PLAYER_IA_BOTTLE_MILK, ITEM_MILK_BOTTLE, 1, true },
{ PLAYER_IA_BOTTLE_POTION_RED, ITEM_POTION_RED, 1, true },
};

static InitChainEntry sInitChain[] = {
Expand Down Expand Up @@ -713,10 +715,16 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, PlayState* play) {

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

if (GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_ACCEPT_RED_POTION, false, requestedItem->itemAction,
presentedItemAction)) { // If requested Blue Potion but presented Red Potion, switch
// requested item to red potion
requestedItem = &sRequestedItemTable[EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_POTION_RED];
}
if (requestedItem->itemAction == presentedItemAction) {
if (!requestedItem->isBottledItem) {
if (AMMO(requestedItem->item) >= requestedItem->amount) {
if ((AMMO(requestedItem->item) >= requestedItem->amount) ||
GameInteractor_Should(VB_GIBDO_TRADE_SEQUENCE_SUFFICIENT_QUANTITY_PRESENTED, false,
requestedItem->item)) {
zodiac-ill marked this conversation as resolved.
Show resolved Hide resolved
return EN_TALK_GIBUD_REQUESTED_ITEM_MET;
} else {
return EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO;
Expand Down Expand Up @@ -782,8 +790,13 @@ 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)) {
Message_StartTextbox(play, 0x1388, &this->actor);
this->textId = 0x1388;
} else {
Message_StartTextbox(play, 0x138A, &this->actor);
this->textId = 0x138A;
}
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 +841,18 @@ 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)) { // 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)) {
Inventory_ChangeAmmo(requestedItem->item, -requestedItem->amount);
} else {
Inventory_ChangeAmmo(requestedItem->item, -1);
}
} else {
Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY);
}
}
player->stateFlags1 |= PLAYER_STATE1_20;
player->stateFlags1 |= PLAYER_STATE1_20000000;
Expand Down
Loading