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

Add traps v2 #1

Open
wants to merge 2 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
30 changes: 25 additions & 5 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,8 @@ typedef enum {
ADD_AMMO_TRAP,
ADD_KILL_TRAP,
ADD_TELEPORT_TRAP,
ADD_REDEAD_TRAP,
ADD_MIRROR_TRAP,
ADD_TRAP_MAX
} AltTrapType;

Expand All @@ -872,7 +874,9 @@ const char* altTrapTypeCvars[] = {
"gAddTraps.Void",
"gAddTraps.Ammo",
"gAddTraps.Kill",
"gAddTraps.Tele"
"gAddTraps.Tele",
"gAddTraps.Redead",
"gAddTraps.Mirror"
};

std::vector<AltTrapType> getEnabledAddTraps () {
Expand All @@ -890,13 +894,15 @@ std::vector<AltTrapType> getEnabledAddTraps () {

void RegisterAltTrapTypes() {
static AltTrapType roll = ADD_TRAP_MAX;
static int statusTimer = -1;
static int speedTimer = -1;
static int mirrorTimer = -1;
static int eventTimer = -1;

GameInteractor::Instance->RegisterGameHook<GameInteractor::OnItemReceive>([](GetItemEntry itemEntry) {
if (!CVarGetInteger("gAddTraps.enabled", 0) || itemEntry.modIndex != MOD_RANDOMIZER || itemEntry.getItemId != RG_ICE_TRAP) {
return;
}
Player* player = GET_PLAYER(gPlayState);
roll = RandomElement(getEnabledAddTraps());
switch (roll) {
case ADD_ICE_TRAP:
Expand All @@ -914,7 +920,7 @@ void RegisterAltTrapTypes() {
case ADD_SPEED_TRAP:
Audio_PlaySoundGeneral(NA_SE_VO_KZ_MOVE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
GameInteractor::State::RunSpeedModifier = -2;
statusTimer = 200;
speedTimer = 200;
Overlay_DisplayText(10, "Speed Decreased!");
break;
case ADD_BOMB_TRAP:
Expand All @@ -934,13 +940,26 @@ void RegisterAltTrapTypes() {
case ADD_TELEPORT_TRAP:
eventTimer = 3;
break;
case ADD_REDEAD_TRAP:
Actor_Spawn(&gPlayState->actorCtx, gPlayState, ACTOR_EN_RD, player->actor.world.pos.x,
player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 22, true);
break;
case ADD_MIRROR_TRAP:
mirrorTimer = 600;
CVarSetInteger("gMirroredWorldMode", 1);
UpdateMirrorModeState(gPlayState->sceneNum);
break;
}
});
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
Player* player = GET_PLAYER(gPlayState);
if (statusTimer == 0) {
if (speedTimer == 0) {
GameInteractor::State::RunSpeedModifier = 0;
}
if (mirrorTimer == 0) {
CVarSetInteger("gMirroredWorldMode", 0);
UpdateMirrorModeState(gPlayState->sceneNum);
}
if (eventTimer == 0) {
switch (roll) {
case ADD_KNOCK_TRAP:
Expand Down Expand Up @@ -991,8 +1010,9 @@ void RegisterAltTrapTypes() {
break;
}
}
statusTimer--;
speedTimer--;
eventTimer--;
mirrorTimer--;
});
}

Expand Down
6 changes: 6 additions & 0 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,12 @@ void DrawEnhancementsMenu() {
UIWidgets::PaddedEnhancementCheckbox("Death Traps", "gAddTraps.Kill", true, false);
UIWidgets::PaddedEnhancementCheckbox("Teleport Traps", "gAddTraps.Tele", true, false);

UIWidgets::PaddedSeparator();
ImGui::Text("Nightmare Traps:");
UIWidgets::Spacer(0);
UIWidgets::PaddedEnhancementCheckbox("Redead Traps", "gAddTraps.Redead", true, false);
UIWidgets::PaddedEnhancementCheckbox("Mirror Traps", "gAddTraps.Mirror", true, false);

ImGui::EndMenu();
}
}
Expand Down
4 changes: 4 additions & 0 deletions soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ void EnRd_Init(Actor* thisx, PlayState* play) {
if (thisx->params == 3) {
thisx->flags |= ACTOR_FLAG_LENS;
}

if (thisx->params == 22) {
func_80AE3260(this, play);
}
}

void EnRd_Destroy(Actor* thisx, PlayState* play) {
Expand Down