Skip to content

Commit

Permalink
added checks to restrict masks from being equipped in some situations…
Browse files Browse the repository at this point in the history
… plus moved CHECK_GIVEN_MASK_ON_MOON to macros.h
  • Loading branch information
mckinlee committed Aug 11, 2024
1 parent 544d73d commit 37dc192
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
18 changes: 18 additions & 0 deletions mm/2s2h/Enhancements/Masks/EasyMaskEquip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
extern "C" {
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "interface/parameter_static/parameter_static.h"
#include "macros.h"
extern u16 sMasksGivenOnMoonBits[];
}

static Vtx* easyMaskEquipVtx;
Expand Down Expand Up @@ -104,6 +106,22 @@ void HandleEasyMaskEquip(PauseContext* pauseCtx) {
if (CHECK_BTN_ALL(CONTROLLER1(&gPlayState->state)->press.button, BTN_A)) {
s16 cursorItem = pauseCtx->cursorItem[PAUSE_MASK];
if (cursorItem != PAUSE_ITEM_NONE) {
Player* player = GET_PLAYER(gPlayState);

// Check if the player is underwater and trying to equip Deku or Goron mask
if ((Player_GetEnvironmentalHazard(gPlayState) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) &&
(Player_GetEnvironmentalHazard(gPlayState) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE) &&
(cursorItem != ITEM_MASK_ZORA)) {
Audio_PlaySfx(NA_SE_SY_ERROR);
return;
}

// Check if the mask is given on the moon
if (CHECK_GIVEN_MASK_ON_MOON(cursorItem - ITEM_NUM_SLOTS)) {
Audio_PlaySfx(NA_SE_SY_ERROR);
return;
}

sPendingMask = cursorItem;
sIsTransforming =
(cursorItem == ITEM_MASK_DEKU || cursorItem == ITEM_MASK_GORON || cursorItem == ITEM_MASK_ZORA ||
Expand Down
3 changes: 3 additions & 0 deletions mm/include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
#define D_0F000000_TO_SEGMENTED (0x0F000000 | 1)
// Used to compare animations. The statically linked global animations can end up with different pointer addresses if an animation gets set from one file and then compared against the static animation in another
#define BEN_ANIM_EQUAL(anim1, anim2) ((anim1 == NULL) ? ((anim2 == NULL) ? true : false) : ((anim2 == NULL) ? false : strcmp(anim1, anim2) == 0))
// Macro to check if a given mask has been given on the moon
#define CHECK_GIVEN_MASK_ON_MOON(maskIndex) \
(gSaveContext.masksGivenOnMoon[sMasksGivenOnMoonBits[maskIndex] >> 8] & (u8)sMasksGivenOnMoonBits[maskIndex])
// #endregion

#endif // MACROS_H
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "BenGui/HudEditor.h"
#include "2s2h/Enhancements/GameInteractor/GameInteractor.h"

#include "macros.h"

#include "2s2h/Enhancements/Masks/EasyMaskEquip.h"

s16 sMaskEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB;
Expand Down Expand Up @@ -160,8 +162,6 @@ u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][MASK_NUM_SLOTS] = {

#define SET_MOON_MASK_BIT(masksGivenOnMoonIndex, masksGivenOnMoonFlag) \
((masksGivenOnMoonIndex) << 8 | (masksGivenOnMoonFlag))
#define CHECK_GIVEN_MASK_ON_MOON(maskIndex) \
(gSaveContext.masksGivenOnMoon[sMasksGivenOnMoonBits[maskIndex] >> 8] & (u8)sMasksGivenOnMoonBits[maskIndex])

u16 sMasksGivenOnMoonBits[] = {
SET_MOON_MASK_BIT(1, 0x1), // SLOT_MASK_POSTMAN
Expand Down

0 comments on commit 37dc192

Please sign in to comment.