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

Invisible Enemies #671

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ void DrawEnhancementsMenu() {
}

if (UIWidgets::BeginMenu("Modes")) {
if (UIWidgets::CVarCheckbox("Invisible Enemies", "gModes.InvisibleEnemies",
{ .tooltip = "Enemies will appear invisible without using the Lens of Truth. "
"Requires scene reload to take effect." })) {
RegisterInvisibleEnemies();
}
UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei",
{ .tooltip = "Requires scene reload to take effect." });
if (UIWidgets::CVarCheckbox("Time Moves When You Move", "gModes.TimeMovesWhenYouMove")) {
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 @@ -57,6 +57,7 @@ void InitEnhancements() {
RegisterCutscenes();

// Modes
RegisterInvisibleEnemies();
RegisterPlayAsKafei();
RegisterTimeMovesWhenYouMove();
}
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Saving/SavingEnhancements.h"
#include "Graphics/DisableBlackBars.h"
#include "Modes/TimeMovesWhenYouMove.h"
#include "Modes/InvisibleEnemies.h"

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

extern "C" {
#include "macros.h"
#include "z64.h"
extern PlayState* gPlayState;
}

void RegisterInvisibleEnemies() {
static HOOK_ID enemyLensReactHookId = 0;
static HOOK_ID roomLensModeHookId = 0;
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnActorInit>(enemyLensReactHookId);
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnRoomInit>(roomLensModeHookId);

if (CVarGetInteger("gModes.InvisibleEnemies", 0)) {
enemyLensReactHookId =
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](Actor* actor) {
if (actor->category == ACTORCAT_ENEMY) {
actor->flags |= ACTOR_FLAG_REACT_TO_LENS;
}
});

roomLensModeHookId = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnRoomInit>(
[](s8 sceneId, s8 roomNum) { gPlayState->roomCtx.curRoom.lensMode = LENS_MODE_HIDE_ACTORS; });
}
}
6 changes: 6 additions & 0 deletions mm/2s2h/Enhancements/Modes/InvisibleEnemies.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef INVISIBLE_ENEMIES_H
#define INVISIBLE_ENEMIES_H

void RegisterInvisibleEnemies();

#endif // INVISIBLE_ENEMIES_H