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

Improve appearance for some age-restricted items #649

Merged
merged 3 commits into from
Mar 10, 2023
Merged
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
3 changes: 2 additions & 1 deletion code/include/z3D/z3Dactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ typedef struct SkeletonAnimationModel {
/* 0x04 */ char unk_04[0x08];
/* 0x0C */ SkeletonAnimationModel_unk_0C* unk_0C;
/* 0x10 */ SkeletonAnimationModel_unk_10* unk_10;
/* 0x14 */ char unk_14[0x68];
/* 0x14 */ void* unk_draw_struct_14;
/* 0x18 */ char unk_18[0x64];
/* 0x7C */ nn_math_MTX34 mtx;
/* 0xAC */ s8 unk_AC;
/* 0xAD */ char unk_AD[0x03];
Expand Down
16 changes: 8 additions & 8 deletions code/oot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ SECTIONS
*(.patch_PlayerEditAndRetrieveCMB)
}

.patch_AdultItemsCMABsAsChild 0x191BB0 : {
*(.patch_AdultItemsCMABsAsChild)
}

.patch_SetChildCustomTunic 0x191DB0 : {
*(.patch_SetChildCustomTunic)
}
Expand Down Expand Up @@ -684,10 +688,6 @@ SECTIONS
*(.patch_GetCustomMessageTextOne)
}

.patch_ChildHoverBoots 0x2D5DF8 : {
*(.patch_ChildHoverBoots)
}

.patch_InstantTextFirstLine 0x2E049C : {
*(.patch_InstantTextFirstLine)
}
Expand Down Expand Up @@ -884,6 +884,10 @@ SECTIONS
*(.patch_IncomingGetItemID)
}

.patch_Model_EnableMeshGroupByIndex 0x372670 : {
*(.patch_Model_EnableMeshGroupByIndex)
}

.patch_MaskSalesmanCheckNoMaskOne 0x372B64 : {
*(.patch_MaskSalesmanCheckNoMask)
}
Expand Down Expand Up @@ -1508,10 +1512,6 @@ SECTIONS
*(.patch_HookshotRotation)
}

.patch_HookshotDrawRedLaser 0x4C2620 : {
*(.patch_HookshotDrawRedLaser)
}

.patch_EditDrawGetItemAfterModelSpawn 0x4C61A4 : {
*(.patch_EditDrawGetItemAfterModelSpawn)
}
Expand Down
16 changes: 8 additions & 8 deletions code/oot_e.ld
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ SECTIONS
*(.patch_PlayerEditAndRetrieveCMB)
}

.patch_AdultItemsCMABsAsChild 0x191BB0 : {
*(.patch_AdultItemsCMABsAsChild)
}

.patch_SetChildCustomTunic 0x191DB0 : {
*(.patch_SetChildCustomTunic)
}
Expand Down Expand Up @@ -684,10 +688,6 @@ SECTIONS
*(.patch_GetCustomMessageTextOne)
}

.patch_ChildHoverBoots 0x2D5DF8 : {
*(.patch_ChildHoverBoots)
}

.patch_InstantTextFirstLine 0x2E049C : {
*(.patch_InstantTextFirstLine)
}
Expand Down Expand Up @@ -884,6 +884,10 @@ SECTIONS
*(.patch_IncomingGetItemID)
}

.patch_Model_EnableMeshGroupByIndex 0x372670 : {
*(.patch_Model_EnableMeshGroupByIndex)
}

.patch_MaskSalesmanCheckNoMaskOne 0x372B64 : {
*(.patch_MaskSalesmanCheckNoMask)
}
Expand Down Expand Up @@ -1508,10 +1512,6 @@ SECTIONS
*(.patch_HookshotRotation)
}

.patch_HookshotDrawRedLaser 0x4C2620 : {
*(.patch_HookshotDrawRedLaser)
}

.patch_EditDrawGetItemAfterModelSpawn 0x4C61A4 : {
*(.patch_EditDrawGetItemAfterModelSpawn)
}
Expand Down
6 changes: 3 additions & 3 deletions code/src/actors/hookshot.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "z3D/z3D.h"
#include "hookshot.h"
#include "player.h"
#include "settings.h"

#define ArmsHook_Init_addr 0x1EBF84
#define ArmsHook_Init ((ActorFunc)ArmsHook_Init_addr)
Expand All @@ -9,13 +9,13 @@

void ArmsHook_rInit(Actor* thisx, GlobalContext* globalCtx) {
ArmsHook_Init(thisx, globalCtx);
if (!Player_ShouldDrawHookshotParts()) {
if (gSaveContext.linkAge == AGE_CHILD) {
thisx->scale.x /= 5;
thisx->scale.y /= 5;
thisx->scale.z /= 5;
}
}

f32 Hookshot_GetZRotation(void) {
return gSaveContext.linkAge == 0 ? *HookshotRotation : -1.4; // TODO find position and lower that
return gSaveContext.linkAge == AGE_ADULT ? *HookshotRotation : -1.4; // TODO find position and lower that
}
27 changes: 16 additions & 11 deletions code/src/actors/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@
u16 healthDecrement = 0;
u8 storedMask = 0;

void* Player_EditAndRetrieveCMB(ZARInfo* zarInfo, u32 objModelIdx) {
void* cmbMan = ZAR_GetCMBByIndex(zarInfo, objModelIdx);
void** Player_EditAndRetrieveCMB(ZARInfo* zarInfo, u32 objModelIdx) {
void** cmbMan = ZAR_GetCMBByIndex(zarInfo, objModelIdx);
void* cmb = *cmbMan;

if (gSettingsContext.customTunicColors == ON) {
if (gSaveContext.linkAge == 0) {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDAE8);
if (gSaveContext.linkAge == AGE_ADULT) {
CustomModel_EditLinkToCustomTunic(cmb);
} else {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDACC);
CustomModel_EditChildLinkToCustomTunic(cmb);
}
}

if (gSettingsContext.stickAsAdult) {
// The unused deku stick will use the same materialIndex as the bow, to make it appear brown.
// This also avoids issues with its combiners being repurposed by the custom tunic patches.
((char*)cmb)[0x4C52] = 5;
}

return cmbMan;
}

Expand Down Expand Up @@ -161,8 +166,12 @@ f32 Player_GetSpeedMultiplier(void) {
return speedMultiplier;
}

s32 Player_ShouldDrawHoverBootsEffect() {
return gSaveContext.linkAge == 0 || !gSettingsContext.hoverbootsAsChild;
s32 Player_IsAdult() {
return gSaveContext.linkAge == AGE_ADULT;
}

s32 Player_ShouldApplyAdultItemsCMABs() {
return gSaveContext.linkAge == AGE_ADULT || gSettingsContext.hoverbootsAsChild || gSettingsContext.hookshotAsChild;
}

s32 Player_ShouldUseSlingshot() {
Expand All @@ -174,10 +183,6 @@ s32 Player_ShouldUseSlingshot() {
}
}

s32 Player_ShouldDrawHookshotParts() {
return gSaveContext.linkAge == 0 || !gSettingsContext.hookshotAsChild;
}

s32 Player_CanPickUpThisActor(Actor* interactedActor) {
switch (interactedActor->id) {
case 0xA: // Chest, can never be picked up
Expand Down
1 change: 0 additions & 1 deletion code/src/actors/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ void PlayerActor_rInit(Actor* thisx, GlobalContext* globalCtx);
void PlayerActor_rUpdate(Actor* thisx, GlobalContext* globalCtx);
void PlayerActor_rDestroy(Actor* thisx, GlobalContext* globalCtx);
void PlayerActor_rDraw(Actor* thisx, GlobalContext* globalCtx);
s32 Player_ShouldDrawHookshotParts(void);

#endif //_PLAYER_H_
33 changes: 15 additions & 18 deletions code/src/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -1333,15 +1333,21 @@ hook_SavewarpSetRespawnFlag:
mov r0,#0xFF
bx lr

.global hook_ChildHoverBoots
hook_ChildHoverBoots:
beq 0x2D5F04
.global hook_AdultItemsCMABsAsChild
hook_AdultItemsCMABsAsChild:
push {r0-r12, lr}
bl Player_ShouldDrawHoverBootsEffect
cmp r0,#0x0
bl Player_ShouldApplyAdultItemsCMABs
cmp r0,#0x1
pop {r0-r12, lr}
beq 0x2D5F04
b 0x2D5DFC
bx lr

.global hook_Model_EnableMeshGroupByIndex
hook_Model_EnableMeshGroupByIndex:
push {r0,r2-r12,lr}
bl Model_OverrideMesh
cpy r1,r0
pop {r0,r2-r12,lr}
b 0x4C8B8C

.global hook_ArrowsOrSeeds
hook_ArrowsOrSeeds:
Expand All @@ -1351,19 +1357,10 @@ hook_ArrowsOrSeeds:
pop {r0-r12, lr}
bx lr

.global hook_HookshotDrawRedLaser
hook_HookshotDrawRedLaser:
push {r0-r12, lr}
bl Player_ShouldDrawHookshotParts
cmp r0,#0x0
pop {r0-r12, lr}
bxeq lr
b 0x4C55C0

.global hook_HookshotDrawChain
hook_HookshotDrawChain:
push {r0-r12, lr}
bl Player_ShouldDrawHookshotParts
bl Player_IsAdult
cmp r0,#0x0
pop {r0-r12, lr}
beq 0x2202BC
Expand All @@ -1381,7 +1378,7 @@ hook_HookshotRotation:
.global hook_LinkReflection
hook_LinkReflection:
push {r0-r12, lr}
bl Player_ShouldDrawHookshotParts
bl Player_IsAdult
cmp r0,#0x1
pop {r0-r12, lr}
streq r1,[r0,#0x714]
Expand Down
15 changes: 15 additions & 0 deletions code/src/models.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "item_table.h"
#include "objects.h"
#include "custom_models.h"
#include "settings.h"
#include "common.h"
#include <stddef.h>

typedef void (*SkeletonAnimationModel_MatrixCopy_proc)(SkeletonAnimationModel* glModel, nn_math_MTX34* mtx);
Expand Down Expand Up @@ -327,3 +329,16 @@ s32 Model_DrawByActor(Actor* actor) {
}
return actorDrawn;
}

u32 Model_OverrideMesh(void* unk, u32 meshGroupIndex) {
// When adult Link holds a deku stick, draw unused deku stick instead of shield.
if (IsInGameOrBossChallenge() && gSaveContext.linkAge == AGE_ADULT && gSettingsContext.stickAsAdult &&
PLAYER->heldItemActionParam == 6 && // holding a deku stick
meshGroupIndex == 23 && // meshGroupIndex for deku stick in child object and shield in adult object
unk == PLAYER->skelAnime.unk_28->unk_draw_struct_14 // check that this is for the player model
) {
return 44; // meshGroupIndex for unused deku stick in adult object
}

return meshGroupIndex;
}
18 changes: 9 additions & 9 deletions code/src/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -1713,10 +1713,15 @@ LHOwlEntranceOverride_patch:
SavewarpSetRespawnFlag_patch:
bl hook_SavewarpSetRespawnFlag

.section .patch_ChildHoverBoots
.global ChildHoverBoots_patch
ChildHoverBoots_patch:
b hook_ChildHoverBoots
.section .patch_AdultItemsCMABsAsChild
.global AdultItemsCMABsAsChild_patch
AdultItemsCMABsAsChild_patch:
bl hook_AdultItemsCMABsAsChild

.section .patch_Model_EnableMeshGroupByIndex
.global Model_EnableMeshGroupByIndex_patch
Model_EnableMeshGroupByIndex_patch:
b hook_Model_EnableMeshGroupByIndex

.section .patch_NockArrow
.global NockArrow_patch
Expand All @@ -1728,11 +1733,6 @@ NockArrow_patch:
DecreaseArrowCount_patch:
bl hook_ArrowsOrSeeds

.section .patch_HookshotDrawRedLaser
.global HookshotDrawRedLaser_patch
HookshotDrawRedLaser_patch:
bl hook_HookshotDrawRedLaser

.section .patch_HookshotDrawChain
.global HookshotDrawChain_patch
HookshotDrawChain_patch:
Expand Down
14 changes: 6 additions & 8 deletions source/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,9 @@ string_view ageItemsInLogicDesc = "Using items as the wrong age may be req
/*------------------------------ //
| ENABLE ADULT DEKU STICK | //
------------------------------*/ //
string_view adultStickDesc = "Adult Link can wield a deku stick. In game Adult\n"
"Link will look like he's holding a Hylian Shield,\n"
"but rest assured it is a deku stick."; //
string_view adultStickDesc = "Adult Link can wield a Deku Stick.\n" //
"It will look like the N64 Deku Stick, but with a\n"
"simpler texture."; //
//
/*------------------------------ //
| ENABLE ADULT BOOMERANG | //
Expand All @@ -993,6 +993,7 @@ string_view adultBoomerangDesc = "Adult Link can throw the boomerang.";
| ENABLE CHILD HAMMER | //
------------------------------*/ //
string_view childHammerDesc = "Child Link can swing the Megaton Hammer."; //
//
/*------------------------------ //
| ENABLE ADULT SLINGSHOT | //
------------------------------*/ //
Expand All @@ -1009,9 +1010,7 @@ string_view childBowDesc = "Child Link can use the Bow. It will loo
| ENABLE CHILD HOOKSHOT | //
------------------------------*/ //
string_view childHookshotDesc = "Child Link can use the Hookshot/Longshot.\n" //
"It will be difficult to aim, the red dot and\n" //
"laser won't appear and the hook will look like\n" //
"a small bomb."; //
"The hook will look like a small bomb."; //
/*------------------------------ //
| ENABLE CHILD IRON BOOTS | //
------------------------------*/ //
Expand All @@ -1020,8 +1019,7 @@ string_view childIronBootsDesc = "Child Link can equip the Iron Boots.";
/*------------------------------ //
| ENABLE CHILD HOVER BOOTS | //
------------------------------*/ //
string_view childHoverBootsDesc = "Child Link can equip the Hover Boots. The yellow\n"
"circle beneath Link's feet won't appear."; //
string_view childHoverBootsDesc = "Child Link can equip the Hover Boots."; //
//
/*------------------------------ //
| ENABLE ADULT MASKS | //
Expand Down