[Enhancement] Instant Recall (#589)

* Instant Recall

* clang it

* Moved to Category "Equipment"

* pr review feedback

---------

Co-authored-by: Archez <archez39@me.com>
This commit is contained in:
Patrick12115 2024-08-18 23:24:14 -04:00 committed by GitHub
parent 542feb038e
commit d74699740e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 0 deletions

View File

@ -515,6 +515,12 @@ void DrawEnhancementsMenu() {
if (UIWidgets::BeginMenu("Equipment")) {
UIWidgets::CVarCheckbox("Fast Magic Arrow Equip Animation", "gEnhancements.Equipment.MagicArrowEquipSpeed",
{ .tooltip = "Removes the animation for equipping Magic Arrows." });
UIWidgets::CVarCheckbox(
"Instant Fin Boomerangs Recall", "gEnhancements.PlayerActions.InstantRecall",
{ .tooltip =
"Pressing B will instantly recall the fin boomerang back to Zora Link after they are thrown." });
ImGui::EndMenu();
}
@ -618,6 +624,7 @@ void DrawEnhancementsMenu() {
}
ImGui::EndMenu();
}
if (UIWidgets::BeginMenu("Player")) {
UIWidgets::CVarSliderInt("Climb speed", "gEnhancements.Player.ClimbSpeed", 1, 5, 1,
{ .tooltip = "Increases the speed at which Link climbs vines and ladders." });

View File

@ -28,6 +28,7 @@ void InitEnhancements() {
// Equipment
RegisterSkipMagicArrowEquip();
RegisterInstantRecall();
// Graphics
RegisterDisableBlackBars();

View File

@ -28,6 +28,7 @@
#include "Restorations/TatlISG.h"
#include "Graphics/3DItemDrops.h"
#include "Graphics/PlayAsKafei.h"
#include "Equipment/InstantRecall.h"
#include "Player/Player.h"
#include "Songs/EnableSunsSong.h"
#include "Songs/PauseOwlWarp.h"

View File

@ -0,0 +1,42 @@
#include <libultraship/bridge.h>
#include "Enhancements/GameInteractor/GameInteractor.h"
#include "InstantRecall.h"
#include "src/overlays/actors/ovl_En_Boom/z_en_boom.h"
extern "C" {
extern PlayState* gPlayState;
}
static HOOK_ID onActorUpdateHookId = 0;
void Player_ReturnBoomerangs() {
Player* player = GET_PLAYER(gPlayState);
if (player == NULL) {
return;
}
EnBoom* boomerangs = (EnBoom*)player->boomerangActor;
// Kill both boomerangs
if (boomerangs != NULL) {
Actor_Kill(&boomerangs->actor);
if (boomerangs->actor.child != NULL) {
Actor_Kill(boomerangs->actor.child);
}
}
}
void RegisterInstantRecall() {
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorUpdate>(onActorUpdateHookId);
onActorUpdateHookId = 0;
onActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorUpdate>(
ACTOR_EN_BOOM, [](Actor* outerActor) {
if (CVarGetInteger("gEnhancements.PlayerActions.InstantRecall", 0)) {
if (CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_B)) {
Player_ReturnBoomerangs();
}
}
});
}

View File

@ -0,0 +1,6 @@
#ifndef EQUIPMENT_INSTAND_RECALL_H
#define EQUIPMENT_INSTAND_RECALL_H
void RegisterInstantRecall();
#endif // EQUIPMENT_INSTAND_RECALL_H