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

[Mod] Hyrule Warriors-style Link #665

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
4 changes: 4 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "2s2h/Enhancements/Graphics/3DItemDrops.h"
#include "2s2h/Enhancements/Graphics/MotionBlur.h"
#include "2s2h/Enhancements/Graphics/PlayAsKafei.h"
#include "2s2h/Enhancements/Graphics/HyruleWarriorsStyledLink.h"
#include "2s2h/Enhancements/Modes/TimeMovesWhenYouMove.h"
#include "2s2h/DeveloperTools/DeveloperTools.h"
#include "2s2h/Enhancements/Cheats/Cheats.h"
Expand Down Expand Up @@ -623,6 +624,9 @@ void DrawEnhancementsMenu() {
if (UIWidgets::BeginMenu("Modes")) {
UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei",
{ .tooltip = "Requires scene reload to take effect." });
UIWidgets::CVarCheckbox("Hyrule Warriors Young Link", "gModes.HyruleWarriorsStyledLink",
{ .tooltip = "When acquired, places the Keaton and Fierce Deity masks on Link "
"similarly to how he wears them in Hyrule Warriors" });
if (UIWidgets::CVarCheckbox("Time Moves When You Move", "gModes.TimeMovesWhenYouMove")) {
RegisterTimeMovesWhenYouMove();
}
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void InitEnhancements() {

// Graphics
RegisterDisableBlackBars();
RegisterHyruleWarriorsStyledLink();
Register3DItemDrops();

// Masks
Expand Down
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "Saving/SavingEnhancements.h"
#include "Graphics/DisableBlackBars.h"
#include "Modes/TimeMovesWhenYouMove.h"
#include "Graphics/HyruleWarriorsStyledLink.h"

enum AlwaysWinDoggyRaceOptions {
ALWAYS_WIN_DOGGY_RACE_OFF,
Expand Down
65 changes: 65 additions & 0 deletions mm/2s2h/Enhancements/Graphics/HyruleWarriorsStyledLink.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "HyruleWarriorsStyledLink.h"
#include "libultraship/libultraship.h"
#include "2s2h/Enhancements/GameInteractor/GameInteractor.h"
#include "Enhancements/FrameInterpolation/FrameInterpolation.h"

extern "C" {
#include "z64.h"
#include "z64player.h"
#include "functions.h"
#include "macros.h"
#include "src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"

extern PlayState* gPlayState;
extern const char* D_801C0B20[28];
extern SaveContext gSaveContext;
#include "objects/object_link_child/object_link_child.h"
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
}

void UpdateHyruleWarriorsStyledLink() {
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnPlayerPostLimbDraw>(
PLAYER_LIMB_HEAD, [](Player* player, s32 limbIndex) {
if (CVarGetInteger("gModes.HyruleWarriorsStyledLink", 0) && player->currentMask == PLAYER_MASK_NONE &&
player->transformation == PLAYER_FORM_HUMAN && INV_CONTENT(ITEM_MASK_KEATON) == ITEM_MASK_KEATON) {
OPEN_DISPS(gPlayState->state.gfxCtx);
Matrix_Push();
Matrix_RotateYS(0x38e3, MTXMODE_APPLY);
Matrix_RotateZS(-0x12F6, MTXMODE_APPLY);
Matrix_Translate(300.0f, -250.0f, 77.7f, MTXMODE_APPLY);
Matrix_Scale(0.648f, 0.648f, 0.648f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gPlayState->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, (Gfx*)D_801C0B20[PLAYER_MASK_KEATON - 1]);
Matrix_Pop();
CLOSE_DISPS(gPlayState->state.gfxCtx);
}
});
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnPlayerPostLimbDraw>(
PLAYER_LIMB_WAIST, [](Player* player, s32 limbIndex) {
if (CVarGetInteger("gModes.HyruleWarriorsStyledLink", 0) && player->transformation == PLAYER_FORM_HUMAN &&
player->itemAction != PLAYER_IA_MASK_FIERCE_DEITY &&
INV_CONTENT(ITEM_MASK_FIERCE_DEITY) == ITEM_MASK_FIERCE_DEITY) {
OPEN_DISPS(gPlayState->state.gfxCtx);
Matrix_Push();
Matrix_RotateXS(-0x61A8, MTXMODE_APPLY);
Matrix_RotateYS(-0x7D0, MTXMODE_APPLY);
Matrix_RotateZS(-0x3A98, MTXMODE_APPLY);
Matrix_Translate(-85.0f, 658.0f, -165.0f, MTXMODE_APPLY);
Matrix_Scale(0.635f, 0.635f, 0.635f, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gPlayState->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, (Gfx*)D_801C0B20[PLAYER_MASK_FIERCE_DEITY - 1]);
Matrix_Pop();
CLOSE_DISPS(gPlayState->state.gfxCtx);
}
});
}

void RegisterHyruleWarriorsStyledLink() {
UpdateHyruleWarriorsStyledLink();

GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>(
[](s8 sceneId, s8 spawnNum) { UpdateHyruleWarriorsStyledLink(); });
}
7 changes: 7 additions & 0 deletions mm/2s2h/Enhancements/Graphics/HyruleWarriorsStyledLink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef GRAPHICS_HYRULE_WARRIORS_STYLED_LINK
#define GRAPHICS_HYRULE_WARRIORS_STYLED_LINK

void RegisterHyruleWarriorsStyledLink();
void UpdateHyruleWarriorsStyledLink();

#endif // GRAPHICS_HYRULE_WARRIORS_STYLED_LINK
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "archives/map_name_static/map_name_static.h"
#include "2s2h/Enhancements/FrameInterpolation/FrameInterpolation.h"
#include "2s2h/Enhancements/Saving/SavingEnhancements.h"
#include "2s2h/Enhancements/GameInteractor/GameInteractor.h"

#include "2s2h_assets.h"

Expand Down