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 Manual Jump from Patcher64+ #695

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Hook system
Quorsor committed Jun 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit a9c9a5568cc87ff088a1d7a64334f06f01042e2b
2 changes: 2 additions & 0 deletions mm/2s2h/BenGui/BenMenuBar.cpp
Original file line number Diff line number Diff line change
@@ -604,6 +604,8 @@ void DrawEnhancementsMenu() {
}
UIWidgets::CVarCheckbox("Instant Putaway", "gEnhancements.Player.InstantPutaway",
{ .tooltip = "Allows Link to instantly puts away held item without waiting." });
UIWidgets::CVarCheckbox("Manual Jump", "gEnhancements.Player.ManualJump",
{ .tooltip = "Z + A to Jump and B while midair to Jump Attack"});
ImGui::EndMenu();
}

1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.cpp
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ void InitEnhancements() {
RegisterClimbSpeed();
RegisterFastFlowerLaunch();
RegisterInstantPutaway();
RegisterManualJump();

// Songs
RegisterEnableSunsSong();
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Enhancements.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
#include "Restorations/TatlISG.h"
#include "Graphics/PlayAsKafei.h"
#include "Player/Player.h"
#include "Player/ManualJump.h"
#include "Songs/EnableSunsSong.h"
#include "Saving/SavingEnhancements.h"
#include "Graphics/DisableBlackBars.h"
43 changes: 43 additions & 0 deletions mm/2s2h/Enhancements/Player/ManualJump.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <libultraship/bridge.h>
#include "Enhancements/GameInteractor/GameInteractor.h"

extern "C" {
#include <z64.h>
#include <macros.h>
#include <global.h>
#include <functions.h>
#include <z64player.h>
#include "objects/gameplay_keep/gameplay_keep.h"
extern PlayState* gPlayState;
extern SaveContext gSaveContext;
extern PlayerAnimationHeader* anim;
void func_80834D50(PlayState* play, Player* player, PlayerAnimationHeader* anim, f32 speed, u16 sfxId);
void func_80834DB8(Player* player, PlayerAnimationHeader* anim, f32 speed, PlayState* play);
}

void RegisterManualJump() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPassPlayerInputs>([](Input * input) {
if (gPlayState == NULL) {
return;
}
if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) {
return;
}
if (CVarGetInteger("gEnhancements.Player.ManualJump", 0)) {
Player* player = GET_PLAYER(gPlayState);
s8 temp = player->unk_AE3[player->unk_ADE];
if (player->stateFlags1 & PLAYER_STATE1_8000 + PLAYER_STATE1_20000) {
if (!(player->stateFlags1 & PLAYER_STATE1_8000000) && (Player_GetMeleeWeaponHeld(player) != PLAYER_MELEEWEAPON_NONE)) {
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
if (temp == 0) {
func_80834D50(gPlayState, player, (PlayerAnimationHeader*)&gPlayerAnim_link_fighter_front_jump , 5.0f, NA_SE_VO_LI_SWORD_N);
}
else if (temp == -1) {
func_80834DB8(player, (PlayerAnimationHeader*)&gPlayerAnim_link_normal_jump, REG(69) / 100.0f, gPlayState);
}
}
}
}
}
});
}
6 changes: 6 additions & 0 deletions mm/2s2h/Enhancements/Player/ManualJump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef PLAYER_MANUAL_JUMP_H
#define PLAYER_MANUAL_JUMP_H

void RegisterManualJump();

#endif // PLAYER_MANUAL_JUMP_H
1 change: 1 addition & 0 deletions mm/2s2h/Enhancements/Player/Player.h
Original file line number Diff line number Diff line change
@@ -4,5 +4,6 @@
void RegisterClimbSpeed();
void RegisterFastFlowerLaunch();
void RegisterInstantPutaway();
void RegisterManualJump();

#endif // PLAYER_H
55 changes: 45 additions & 10 deletions mm/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
@@ -47,6 +47,41 @@

#include "2s2h/Enhancements/GameInteractor/GameInteractor.h"

#define BIT32_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c"
#define BIT32_TO_BINARY(BIT32) \
((BIT32) & 0x80000000 ? '1' : '0'), \
((BIT32) & 0x40000000 ? '1' : '0'), \
((BIT32) & 0x20000000 ? '1' : '0'), \
((BIT32) & 0x10000000 ? '1' : '0'), \
((BIT32) & 0x08000000 ? '1' : '0'), \
((BIT32) & 0x04000000 ? '1' : '0'), \
((BIT32) & 0x02000000 ? '1' : '0'), \
((BIT32) & 0x01000000 ? '1' : '0'), \
((BIT32) & 0x00800000 ? '1' : '0'), \
((BIT32) & 0x00400000 ? '1' : '0'), \
((BIT32) & 0x00200000 ? '1' : '0'), \
((BIT32) & 0x00100000 ? '1' : '0'), \
((BIT32) & 0x00080000 ? '1' : '0'), \
((BIT32) & 0x00040000 ? '1' : '0'), \
((BIT32) & 0x00020000 ? '1' : '0'), \
((BIT32) & 0x00010000 ? '1' : '0'), \
((BIT32) & 0x00008000 ? '1' : '0'), \
((BIT32) & 0x00004000 ? '1' : '0'), \
((BIT32) & 0x00002000 ? '1' : '0'), \
((BIT32) & 0x00001000 ? '1' : '0'), \
((BIT32) & 0x00000800 ? '1' : '0'), \
((BIT32) & 0x00000400 ? '1' : '0'), \
((BIT32) & 0x00000200 ? '1' : '0'), \
((BIT32) & 0x00000100 ? '1' : '0'), \
((BIT32) & 0x00000080 ? '1' : '0'), \
((BIT32) & 0x00000040 ? '1' : '0'), \
((BIT32) & 0x00000020 ? '1' : '0'), \
((BIT32) & 0x00000010 ? '1' : '0'), \
((BIT32) & 0x00000008 ? '1' : '0'), \
((BIT32) & 0x00000004 ? '1' : '0'), \
((BIT32) & 0x00000002 ? '1' : '0'), \
((BIT32) & 0x00000001 ? '1' : '0')

#define THIS ((Player*)thisx)

void Player_Init(Actor* thisx, PlayState* play);
@@ -7969,13 +8004,13 @@ s32 func_80839A84(PlayState* play, Player* this) {
return true;
}

//Z target
// Z target but doesn't activate when you're swimming
s32 Player_ActionChange_10(Player* this, PlayState* play) {
if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) &&
(play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sPlayerFloorType != FLOOR_TYPE_7) &&
(sPlayerFloorEffect != FLOOR_EFFECT_1)) {
s32 temp_a2 = this->unk_AE3[this->unk_ADE];
//covers when link is staying put and when link is moving forward
// covers when link is staying put and when link is moving forward
if (temp_a2 <= 0) {
if (func_8082FBE8(this)) {
if (this->actor.category != ACTORCAT_PLAYER) {
@@ -7985,23 +8020,23 @@ s32 Player_ActionChange_10(Player* this, PlayState* play) {
func_80836B3C(play, this, 0.0f);
}
}
//Jump/Leap (Was jump slash)
// Jump/Leap (Was jump slash)
else if (!(this->stateFlags1 & PLAYER_STATE1_8000000) &&
(Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) &&
Player_CanUpdateItems(this) && (this->transformation != PLAYER_FORM_GORON)) {
if (this->transformation == PLAYER_FORM_ZORA) {func_808395F0(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f);}
//Leap
else if (temp_a2 == 0) {func_80834D50(play, this, D_8085C2A4[0].unk_0, 5.0f, NA_SE_VO_LI_SWORD_N);}
//Jump
else {func_80834DB8(this, &gPlayerAnim_link_normal_jump, REG(69) / 100.0f, play);}

// if (this->transformation == PLAYER_FORM_ZORA) {func_808395F0(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f);}
// // Leap
// else if (temp_a2 == 0) {func_80834D50(play, this, D_8085C2A4[0].unk_0, 5.0f, NA_SE_VO_LI_SWORD_N);}
// // Jump
// else {func_80834DB8(this, &gPlayerAnim_link_normal_jump, REG(69) / 100.0f, play);}
func_808395F0(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f);
} else if (!func_80839A84(play, this)) {
func_80836B3C(play, this, 0.0f);
}

return true;
}
//covers when link is backflipping or sidehopping
// covers when link is backflipping or sidehopping
} else {
func_80839860(this, play, temp_a2);
return true;