Skip to content

Commit

Permalink
Add instant boomerang recall
Browse files Browse the repository at this point in the history
  • Loading branch information
lilDavid committed Aug 2, 2022
1 parent 9389ceb commit 0135c33
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions libultraship/libultraship/ImGuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,8 @@ namespace SohImGui {
Tooltip("Allow Link to put items away without having to wait around");
EnhancementCheckbox("Mask Select in Inventory", "gMaskSelect");
Tooltip("After completing the mask trading sub-quest, press A and any direction on the mask slot to change masks");
EnhancementCheckbox("Instant Boomerang Recall", "gFastBoomerang");
Tooltip("Instantly return the boomerang to Link by pressing its item button while it's in the air");
ImGui::EndMenu();
}

Expand Down
3 changes: 2 additions & 1 deletion soh/include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ typedef struct Player {
/* 0x0A86 */ s8 unk_A86;
/* 0x0A87 */ u8 unk_A87;
/* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position
} Player; // size = 0xA94
/* 0x0A94 */ u8 boomerangQuickRecall; // Has the player pressed the boomerang button while it's in the air still?
} Player; // size = 0xA95

#endif
7 changes: 4 additions & 3 deletions soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) {

// Decrement the return timer and check if it's 0. If it is, check if Link can catch it and handle accordingly.
// Otherwise handle grabbing and colliding.
if (DECR(this->returnTimer) == 0) {
if (DECR(this->returnTimer) == 0 || player->boomerangQuickRecall) {
distFromLink = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos);
this->moveTo = &player->actor;

// If the boomerang is less than 40 units away from Link, he can catch it.
if (distFromLink < 40.0f) {
if (distFromLink < 40.0f || player->boomerangQuickRecall) {
target = this->grabbed;
if (target != NULL) {
Math_Vec3f_Copy(&target->world.pos, &player->actor.world.pos);
Expand All @@ -187,7 +187,8 @@ void EnBoom_Fly(EnBoom* this, GlobalContext* globalCtx) {
}
}
// Set player flags and kill the boomerang beacause Link caught it.
player->stateFlags1 &= ~0x02000000;
player->stateFlags1 &= ~PLAYER_STATE1_25;
player->boomerangQuickRecall = false;
Actor_Kill(&this->actor);
}
} else {
Expand Down
17 changes: 11 additions & 6 deletions soh/src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ s32 func_808353D8(Player* this, GlobalContext* globalCtx);
s32 func_80835588(Player* this, GlobalContext* globalCtx);
s32 func_808356E8(Player* this, GlobalContext* globalCtx);
s32 func_80835800(Player* this, GlobalContext* globalCtx);
s32 func_80835884(Player* this, GlobalContext* globalCtx);
s32 func_808358F0(Player* this, GlobalContext* globalCtx);
s32 func_808359FC(Player* this, GlobalContext* globalCtx);
s32 func_80835B60(Player* this, GlobalContext* globalCtx);
s32 func_80835884(Player* this, GlobalContext* globalCtx); // Start aiming boomerang
s32 func_808358F0(Player* this, GlobalContext* globalCtx); // Aim boomerang
s32 func_808359FC(Player* this, GlobalContext* globalCtx); // Throw boomerang
s32 func_80835B60(Player* this, GlobalContext* globalCtx); // Boomerang active
s32 func_80835C08(Player* this, GlobalContext* globalCtx);
void func_80835F44(GlobalContext* globalCtx, Player* this, s32 item);
void func_80839F90(Player* this, GlobalContext* globalCtx);
Expand Down Expand Up @@ -486,8 +486,8 @@ static s32 D_80853604 = 0;
static s32 D_80853608 = 0;
static s32 D_8085360C = 0;
static s16 D_80853610 = 0;
static s32 D_80853614 = 0;
static s32 D_80853618 = 0;
static s32 D_80853614 = 0; // Held item button just pressed?
static s32 D_80853618 = 0; // Held item button currently down?

static u16 D_8085361C[] = {
NA_SE_VO_LI_SWEAT,
Expand Down Expand Up @@ -954,6 +954,7 @@ static s8 sItemActionParams[] = {

static u8 sMaskMemory;

// Used to map action params to update functions
static s32(*D_80853EDC[])(Player* this, GlobalContext* globalCtx) = {
func_8083485C, func_8083485C, func_8083485C, func_808349DC, func_808349DC, func_808349DC, func_8083485C,
func_8083485C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C, func_8083501C,
Expand Down Expand Up @@ -2728,6 +2729,10 @@ s32 func_80835B60(Player* this, GlobalContext* globalCtx) {
return 1;
}

if (D_80853614 && CVar_GetS32("gFastBoomerang", 0)) {
this->boomerangQuickRecall = true;
}

return 0;
}

Expand Down

0 comments on commit 0135c33

Please sign in to comment.