-
Notifications
You must be signed in to change notification settings - Fork 87
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
garrettjoecox
merged 11 commits into
HarbourMasters:develop
from
zodiac-ill:gibdo-trade-sequence-options
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f71159a
Add Gibdo Trade Sequence Options
zodiac-ill 53b3331
clang-format
zodiac-ill 03d4ad1
hopefully fixes clang-format?
zodiac-ill 5529451
actually fix clang-format now
zodiac-ill 91dd08a
I accidentally put the file in the wrong place somehow
zodiac-ill 7b52408
clang-format
zodiac-ill 64d4960
Relocate to difficulty options
zodiac-ill c811a54
Merge branch 'develop' into gibdo-trade-sequence-options
zodiac-ill db27562
feedback
zodiac-ill c979de6
Let's not relocate EnTalkGibudRequestedItem struct def
zodiac-ill ab0b008
feedback 2
zodiac-ill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
mm/2s2h/Enhancements/DifficultyOptions/GibdoTradeSequenceOptions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Cheats.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 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a nested pointer? I think you can get away with just the top level pointer and changing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The top-level pointer
requestedItem
points to thesRequestedItemTable
entry that contains the blue potion. If I passedrequestedItem
by copy to the hook, that would leave with the ability to alter the vanilla table, which I definitely want to avoid. If I had altered the table, and the player switched back to Vanilla behavior, the gibdo would only take a red potion, and not a blue one. So I definitely don't want to change what's already there, I found that the cleanest solution is to just pass a pointer to that pointer and change what it is pointing to, which would be our own entry.