Tweak the elegy statue spawning state to improve usability

* Spawn the statue as soon as possible.
* Give control to the player only after the statue is at the right
  position to help prevent floor switches from resetting.

This replaces the previous "elegy statue cutscene skip" patch.
This commit is contained in:
Léo Lam
2020-04-29 16:44:07 +02:00
parent d82730564b
commit 91149f5dfa
3 changed files with 22 additions and 10 deletions

View File

@@ -29,6 +29,11 @@ struct TVec3 {
T y;
T z;
constexpr bool operator==(const TVec3& rhs) const {
return x == rhs.x && y == rhs.y && z == rhs.z;
}
constexpr bool operator!=(const TVec3& rhs) const { return !(*this == rhs); }
T Distance(const TVec3& other) const {
const T delta_x = x - other.x;
const T delta_y = y - other.y;

View File

@@ -1,6 +1,7 @@
#include "game/player.h"
#include "common/utils.h"
#include "game/actors/obj_elegy_statue.h"
#include "game/common_data.h"
#include "rst/link.h"
@@ -69,16 +70,21 @@ RST_HOOK void PlayerStateSpawningElegyStatue(Player* player, GlobalContext* gctx
++player->timer;
if (player->timer == 15) {
// Spawn the statue as soon as possible.
if (player->timer == 1) {
auto spawn_elegy_statue = rst::util::GetPointer<void(GlobalContext*, Player*)>(0x1F0758);
spawn_elegy_statue(gctx, player);
} else {
const bool skip_requested =
player->timer > 15 && pad.input.new_buttons.IsOneSet(pad::Button::X, pad::Button::Y,
pad::Button::A, pad::Button::B);
if (skip_requested || player->timer > 135) {
auto* statue = gctx->elegy_statues[u8(player->active_form)];
statue->timer = 0;
} else if (player->timer > 5) {
auto* statue = gctx->elegy_statues[u8(player->active_form)];
const bool statue_ready = !statue || statue->pos.pos == player->pos.pos;
if (player->timer > 135 || statue_ready) {
gctx->ocarina_state = OcarinaState::StoppedPlaying;
PlayerChangeStateToStill(player, gctx);
} else if (statue && !statue_ready) {
// Speed up the statue fadeout. (0x18 + 8 = 0x20 per game tick)
statue->opacity = std::max(int(statue->opacity) - 0x18, 0);
}
}
}

View File

@@ -430,10 +430,11 @@ stone_tower_block_faster_movement:
addr: 0x2D0C0C
data: 00 00 A0 42
elegy_auto_cancel_elegy_spawn_mini_cutscene:
type: patch
addr: 0x1E9FF8
data: 01 00 00 EA
player_state_spawning_elegy_statue:
type: branch
link: false
addr: 0x1E9FB8
func: game::act::PlayerStateSpawningElegyStatue(game::act::Player*, game::GlobalContext*)
ocarina_dive_restore:
type: patch