diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml new file mode 100644 index 0000000000..d48335ec7a --- /dev/null +++ b/assets/xml/code/sub_s.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/functions.h b/include/functions.h index 3f22bd67b7..ed9c8541b9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2439,8 +2439,8 @@ void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); +Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); @@ -2451,14 +2451,14 @@ void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); -Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); @@ -2466,17 +2466,18 @@ void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); -s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); -s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); -s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); -s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); -s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCount(Path* paths, s32 index); void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); diff --git a/include/z64subs.h b/include/z64subs.h index 7ef51c3482..ca69e72cb6 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -10,7 +10,7 @@ typedef enum { /* 2 */ SUBS_CUTSCENE_SET_FLAG } SubSCutsceneType; -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); diff --git a/spec b/spec index 4b23e05512..0bfd745045 100644 --- a/spec +++ b/spec @@ -530,7 +530,6 @@ beginseg include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" - include "build/data/code/z_sub_s.data.o" include "build/data/code/code_801DE890.rodata.o" include "build/src/code/code_8013EC10.o" include "build/data/code/code_8013EC10.bss.o" diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index ab42ea6226..6b16cc91cc 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -152,7 +152,7 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 EnDoor* door; s32 pad; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -174,7 +174,7 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { EnDoor* door; enHy->curPoint = 0; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; @@ -209,7 +209,8 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; if (enHy->curPoint >= enHy->path->count) { reachedEnd = true; @@ -226,7 +227,8 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; if (enHy->curPoint < 0) { reachedEnd = true; @@ -263,12 +265,12 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 630b164630..c36365d486 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -6,10 +6,18 @@ #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; + +#include "code/sub_s/sub_s.c" + +Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; + +s32 D_801C5DBC[] = { 0, 1 }; // Unused + /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; @@ -21,7 +29,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { break; } @@ -170,7 +178,21 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + Path* path; + s32 i = 0; + + do { + path = &globalCtx->setupPathList[pathIndex]; + if (i >= max) { + break; + } + pathIndex = path->unk1; + i++; + } while (pathIndex != 0xFF); + + return path; +} /** * Finds the nearest actor instance of a specified Id and category to an actor. @@ -228,15 +250,88 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 count = path->count; + s32 index = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s") + Math_Vec3s_ToVec3f(&point, &points[index]); + + if (index == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (index == count - 1) { + diffX = points[count - 1].x - points[count - 2].x; + diffZ = points[count - 1].z - points[count - 2].z; + } else { + diffX = points[index + 1].x - points[index - 1].x; + diffZ = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + if (((px * actor->world.pos.x) + (pz * actor->world.pos.z) + d) > 0.0f) { + reached = true; + } + + return reached; +} + +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { + Path* path = NULL; + s32 found = false; + s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + + ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) / + 30; + s32 day = CURRENT_DAY; + + if (pathIndex == max) { + return NULL; + } + + while (pathIndex != 0xFF) { + path = &globalCtx->setupPathList[pathIndex]; + if (sPathDayFlags[day] & path->unk2) { + found = true; + break; + } + pathIndex = path->unk1; + } + + if (found == true) { + *startPointIndex = time; + *startPointIndex = CLAMP(*startPointIndex, 0, path->count - 1); + } else { + *startPointIndex = 0; + } + + return path; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s") +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; + + if ((path == NULL) || (pointIndex >= path->count) || (pointIndex < 0)) { + return false; + } + + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + return true; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") @@ -254,15 +349,68 @@ s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s") +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s") + if (path == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") + return true; +} + +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq) { + f32 diffX = vecA->x - vecB->x; + f32 diffZ = vecA->z - vecB->z; + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +/** + * Returns true when the actor has reached the inputed point + */ +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep) { + Vec3f offsetBefore; + Vec3f offsetAfter; + f32 distSqBefore; + f32 distSqAfter; + + Actor_OffsetOfPointInActorCoords(actor, &offsetBefore, point); + Math_SmoothStepToS(&actor->world.rot.y, SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqBefore), 4, + rotStep, 1); + actor->shape.rot.y = actor->world.rot.y; + Actor_MoveWithGravity(actor); + Actor_OffsetOfPointInActorCoords(actor, &offsetAfter, point); + SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqAfter); + return ((offsetBefore.z > 0.0f) && (offsetAfter.z <= 0.0f)) ? true : false; +} + +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { + Vec3s* point; + f32 diffX = 0.0f; + f32 diffZ = 0.0f; + + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; + } + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; @@ -301,11 +449,35 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li return true; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { + CollisionPoly* outPoly; + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s") + posA = posB = *pos; + posB.y += distAbove; + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, + &bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { + Path* path = &paths[pathIndex]; + Vec3s* point = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[pointIndex]; + + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + + return false; +} + +u8 SubS_GetPathCount(Path* paths, s32 index) { + Path* path = &paths[index]; + + return path->count; +} void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 2648b3069c..9020f368ca 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -328,7 +328,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -350,7 +350,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); if (this->unk164 != 0) { sp38 = Lib_SegmentedToVirtual(this->unk164->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); @@ -361,7 +361,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = func_8013BB34(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c index 21691cbf8e..70e98fc15f 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -1606,7 +1606,7 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; diff --git a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c index ecbb734007..0705d7f06e 100644 --- a/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c +++ b/src/overlays/actors/ovl_En_Aob_01/z_en_aob_01.c @@ -113,7 +113,7 @@ void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index 7ce0ea2609..ff2d7c48e7 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -266,7 +266,7 @@ s32 func_80BA8D2C(EnBaba* this, f32 arg1) { Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); sp3E = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk_1E8, &sp2C) && func_8013D768(&this->actor, &sp2C, sp3E)) { + if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { this->unk_1E8++; if (this->unk_1E8 >= this->path->count) { ret = true; @@ -311,7 +311,7 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* u8 sp23 = ENBABA_GET_3F00(&this->actor); if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = func_8013BB34(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); } if (this->unk_410 == NULL) { @@ -659,7 +659,7 @@ void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + this->path = SubS_GetPathByIndex(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c index 00f4be6e8e..e502b6637c 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.c @@ -220,7 +220,7 @@ void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnBba01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index 49e6caa637..321468424f 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -94,7 +94,7 @@ void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); - this->path = func_8013D648(globalCtx, this->unk_29A, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); this->unk_2C8 = 80.0f; if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && @@ -157,7 +157,7 @@ void func_809C4B50(EnBomBowlMan* this) { void func_809C4B6C(EnBomBowlMan* this) { if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { - if (!func_8013D68C(this->path, this->unk_298, &this->unk_2A0)) { + if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c index 3d8623e7a0..e7c6ebc6ef 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.c @@ -210,7 +210,7 @@ void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->enHy.actor.flags &= ~ACTOR_FLAG_1; - this->enHy.path = func_8013D648(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); this->enHy.waitingOnInit = true; Actor_SetScale(&this->enHy.actor, 0.01f); this->enHy.actionFunc = EnCne01_FinishInit; diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index a15d095159..3d76b73919 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -67,7 +67,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = ENDAIKU_GET_FF(&this->actor); if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { this->unk_288 = ENDAIKU_GET_FF00(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -134,7 +134,7 @@ void func_8094373C(EnDaiku* this, s32 arg1) { void func_809437C8(EnDaiku* this) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { - if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c index 009094f93d..64a8c3d9b3 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -70,7 +70,7 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { - if (func_8013D68C(this->unk_258, this->unk_25C, &this->unk_268) == 0) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { Actor_MarkForDeath(&this->actor); } } @@ -88,7 +88,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.c b/src/overlays/actors/ovl_En_Dg/z_en_dg.c index 5d477d21f1..dce730c481 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -212,7 +212,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { if (idx == 0) { phi_f12 = sp5C[1].x - sp5C[0].x; phi_f14 = sp5C[1].z - sp5C[0].z; - } else if ((idx + 1) == ((void)0, count)) { + } else if (idx == count - 1) { phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; } else { @@ -220,7 +220,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, func_80086B30(phi_f12, phi_f14) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { sp50 = true; } @@ -1114,7 +1114,7 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = func_8013D648(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index 7b019933fc..ebe127fcff 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -369,7 +369,7 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, this->morphTable, 20); - this->unk_1D8 = func_8013D648(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->unk_1D8 = SubS_GetPathByIndex(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); this->actor.flags &= ~ACTOR_FLAG_80; this->unk_2F0 = 0; this->unk_2F1 = 0; diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index 135d9f6d7c..059f18c9c2 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -1028,7 +1028,7 @@ void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } else { this->unk_318 = this->actor.cutscene; - this->path = func_8013D648(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->path = SubS_GetPathByIndex(globalCtx, ENGK_GET_F0(&this->actor), 15); this->actionFunc = func_80B51760; } } else if (globalCtx->sceneNum == SCENE_GORONRACE) { diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 50a809dfd5..107c9a656e 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -902,7 +902,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -933,7 +933,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar door = func_8094DF90(globalCtx, arg2->unk0); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -974,7 +974,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1076,7 +1076,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if (this->unk_234 != NULL) { diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index dbe7c3d72b..57c8dc0448 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -1332,7 +1332,7 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { this->actor.flags &= ~ACTOR_FLAG_2000000; - func_8013C8B8(this->unk_284, 0, &sp24); + SubS_CopyPointFromPathCheckBounds(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; this->actor.world.rot.y = temp; @@ -1393,7 +1393,7 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { if (gSaveContext.save.day >= 2) { - this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } @@ -1785,7 +1785,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); - if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (SubS_HasReachedPoint(&this->actor, this->unk_284, this->unk_3E4)) { if (this->unk_3E4 >= (this->unk_284->count - 1)) { this->unk_3E4 = 0; } else { diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 4ea774d713..e1432c10a3 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -103,7 +103,7 @@ void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - this->path = func_8013D648(globalCtx, this->unk_21E, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); this->unk_226 = this->actor.cutscene; func_801A5080(2); func_80BDB268(this); @@ -311,7 +311,7 @@ void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); this->unk_208 = 1; - if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_MarkForDeath(&this->actor); } @@ -376,7 +376,7 @@ void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { this->unk_208++; if (this->unk_208 >= this->path->count) { func_80BDBE70(this, globalCtx); - } else if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_208, &this->unk_20C)) { + } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index 6ab8fb486e..7f847cf087 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -478,7 +478,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -522,7 +522,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar door = func_80BF1200(globalCtx, arg2->unk0); if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -563,7 +563,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -613,7 +613,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index f3293f6dde..57c4bfe475 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -165,11 +165,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -286,7 +286,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { this->unk244 = 0; @@ -1382,7 +1382,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { if (GET_RACE_FLAGS == RACE_FLAG_2 || (GET_RACE_FLAGS) == RACE_FLAG_3) { diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 8bc5df4cc1..9412e55948 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -957,7 +957,7 @@ void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnJg_LullabyIntroCutsceneAction; } else { // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. - this->path = func_8013D648(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; this->action = EN_JG_ACTION_SPAWNING; this->freezeTimer = 1000; diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c index f93851035a..d687c2aa86 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.c @@ -164,9 +164,9 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { return; } - this->path = func_8013D648(globalCtx, this->pathLocation, 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); if (this->path != NULL) { - sp34 = func_8013D83C(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); } if (sp30 < 10.0f) { diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 27c7af9f5b..2736fc71a1 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -916,7 +916,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -947,7 +947,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; door = func_80AF7D60(globalCtx, arg2->unk0); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -992,7 +992,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1072,7 +1072,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1125,7 +1125,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; phi_a3 = D_80AFB430[arg2->unk0]; if (phi_a3 >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 6fa76d817b..39f1e4f956 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -152,7 +152,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { if (parent->update != NULL) { this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; - this->path = func_8013D648(globalCtx, this->unk_1C8, 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); this->unk_208 = parent->world.rot.z * 20.0f; if (this->unk_208 < 20.0f) { this->unk_208 = 20.0f; @@ -276,7 +276,7 @@ void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); } - if ((this->path != NULL) && !func_8013D68C(this->path, this->unk_1D0, &this->unk_21C)) { + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c index 064c2d2e48..0166ed4235 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -225,7 +225,7 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1E0 = func_8013D648(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.gravity = -3.0f; if (ENRACEDOG_GET_3E0(&this->actor) < 14) { diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index 4e41b70a94..bf7158d73f 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -383,8 +383,8 @@ s32 func_80BF43FC(EnRg* this) { s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; while (true) { - func_8013C8B8(this->path, phi_s0 - 1, &sp9C); - func_8013C8B8(this->path, phi_s0 + 1, &sp90); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, &sp8C, &sp88, &sp84) && (!phi_s6 || ((phi_s4 + 1) == phi_s0) || (sp84 < phi_f20))) { @@ -521,7 +521,7 @@ void func_80BF4964(EnRg* this) { if (this->path != NULL) { sp3C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_33C)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_33C)) { if ((this->path->count - 1) < (this->unk_33C + 1)) { this->unk_33C = this->path->count - 1; } else { @@ -749,7 +749,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = func_8013BEDC(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c index c21395ef5c..2b4026858a 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -639,7 +639,7 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_SetScale(&this->actor, 0.01f); this->actor.flags |= ACTOR_FLAG_2000000; - this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { diff --git a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c index cf4935187d..dc7715fa07 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -708,7 +708,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -717,7 +717,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { if (gSaveContext.save.weekEventReg[52] & 0x40) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { diff --git a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c index 199338bf17..5735d1e28d 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -915,7 +915,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, func_80086B30(pointX, pointY) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(pointX, pointY)), &sp44, &sp40, &sp3C); if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { ret = true; } @@ -957,7 +957,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 8579dc8f0d..fc2ba14320 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -53,7 +53,7 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); static AnimationInfoS sAnimationsBombShopkeeper[] = { { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, @@ -711,10 +711,9 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); if (distSq < 12.0f) { @@ -750,10 +749,9 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } if (this->path != NULL) { - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { @@ -1249,7 +1247,7 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; @@ -1375,7 +1373,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->pathPointsIdx = 0; if (this->shopType == BOMB_SHOP) { - this->path = func_8013D648(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index a989ee8ad9..dafed18c5a 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -473,8 +473,8 @@ void func_80BAB434(EnSuttari* this) { } void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = func_8013D648(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = func_8013D648(globalCtx, this->paths[0]->unk1, 0x3F); + this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { @@ -504,28 +504,29 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } -s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { diffX = 0.0f; diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); - return Math_Acot2F(diffZ, diffX) * (0x8000 / M_PI); + + *distSq = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); s32 sp58 = path->count; - s32 idx = arg2; + s32 index = arg2; s32 ret = false; f32 sp54; f32 sp48; @@ -534,16 +535,16 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { f32 sp3C; Vec3f sp30; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (idx == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; - sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; + sp54 = sp5C[index + 1].x - sp5C[index - 1].x; + sp48 = sp5C[index + 1].z - sp5C[index - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -554,29 +555,26 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 index = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2 - 1].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[0].x - sp5C[1].x; sp48 = sp5C[0].z - sp5C[1].z; - } else if (arg2 == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 2].x - sp5C[sp58 - 1].x; sp48 = sp5C[sp58 - 2].z - sp5C[sp58 - 1].z; } else { - sp54 = sp5C[arg2 - 1].x - sp5C[arg2 + 1].x; - sp48 = sp5C[arg2 - 1].z - sp5C[arg2 + 1].z; + sp54 = sp5C[index - 1].x - sp5C[index + 1].x; + sp48 = sp5C[index - 1].z - sp5C[index + 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -590,7 +588,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { f32 dist; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); if (this->actor.bgCheckFlags & 8) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; @@ -619,7 +617,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { f32 sp30; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } @@ -644,7 +642,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg u16 phi_a0; if (sp1C >= 0) { - this->unk404 = func_8013BB34(globalCtx, sp23, sp1C); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } if (this->unk404 == NULL) { return 0; @@ -686,7 +684,7 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); sp24 = D_80BAE8F8[unkStruct->unk0]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = func_8013BB34(globalCtx, sp47, sp24); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } if ((sp48 == NULL) || (this->unk404 == NULL)) { return 0; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 3db46de496..f0d1a3aa72 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -1175,7 +1175,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 58d0fc0a2e..3c72de53d9 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -507,7 +507,7 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar u16 phi_a1; s32 idx = arg2->unk0 - 1; - this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { return false; } diff --git a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c index bca0f4b84e..0af7ac4bb0 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -203,7 +203,7 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { this->unk_1E4 = 0; this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; - this->path = func_8013D648(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -437,7 +437,7 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; @@ -708,7 +708,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10; Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index e3bfe7f361..909cc2f99e 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -723,7 +723,7 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { if (this->path != NULL) { sp4C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_384)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; ret = true; @@ -1127,7 +1127,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = func_8013BEDC(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c index 37715b5138..e191cc3cd3 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.c @@ -412,7 +412,7 @@ void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 22; this->actor.colChkInfo.damageTable = &sDamageTable; - this->path = func_8013D648(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); this->actor.targetMode = 0; Actor_SetScale(&this->actor, 0.008f); @@ -420,7 +420,7 @@ void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_328 = 0; this->actor.room = -1; - this->path = func_8013D648(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); func_80B76030(&this->skelAnime, 14); this->actionFunc = func_80B76A64; } diff --git a/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 3a9872406c..0f91171fbc 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -141,12 +141,12 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -218,7 +218,7 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); speed = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->waypoint, &pos) && func_8013D768(&this->actor, &pos, speed)) { + if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { this->waypoint = 0; @@ -259,7 +259,7 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 0c6eedbad4..bd7da8ff20 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -452,6 +452,18 @@ animdict = { "func_8013E054": "SubS_ActorPathing_MoveWithGravity", "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", + "func_8013BB34": "SubS_GetAdditionalPath", + "func_8013BD40": "SubS_HasReachedPoint", + "func_8013BEDC": "SubS_GetDayDependentPath", + "func_8013C8B8": "SubS_CopyPointFromPathCheckBounds", + "func_8013D648": "SubS_GetPathByIndex", + "func_8013D68C": "SubS_CopyPointFromPath", + "func_8013D720": "SubS_GetDistSqAndOrientPoints", + "func_8013D768": "SubS_MoveActorToPoint", + "func_8013D83C": "SubS_GetDistSqAndOrientPath", + "func_8013DB90": "SubS_IsFloorAbove", + "func_8013DC40": "SubS_CopyPointFromPathList", + "func_8013DCCC": "SubS_GetPathCount", "func_80147624": "Message_ShouldAdvance", "func_80147734": "Message_ShouldAdvanceSilent", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 46d8713728..a49849eec2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2667,14 +2667,14 @@ 0x8013B350:("func_8013B350",), 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), - 0x8013BB34:("func_8013BB34",), + 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), - 0x8013BD40:("func_8013BD40",), - 0x8013BEDC:("func_8013BEDC",), + 0x8013BD40:("SubS_HasReachedPoint",), + 0x8013BEDC:("SubS_GetDayDependentPath",), 0x8013C068:("func_8013C068",), 0x8013C624:("func_8013C624",), - 0x8013C8B8:("func_8013C8B8",), + 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("func_8013CC2C",), 0x8013CD64:("func_8013CD64",), @@ -2682,18 +2682,18 @@ 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), 0x8013D5E8:("SubS_AngleDiffLessEqual",), - 0x8013D648:("func_8013D648",), - 0x8013D68C:("func_8013D68C",), - 0x8013D720:("func_8013D720",), - 0x8013D768:("func_8013D768",), - 0x8013D83C:("func_8013D83C",), + 0x8013D648:("SubS_GetPathByIndex",), + 0x8013D68C:("SubS_CopyPointFromPath",), + 0x8013D720:("SubS_GetDistSqAndOrientPoints",), + 0x8013D768:("SubS_MoveActorToPoint",), + 0x8013D83C:("SubS_GetDistSqAndOrientPath",), 0x8013D8DC:("SubS_IsObjectLoaded",), 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), 0x8013D9C8:("SubS_FillLimbRotTables",), - 0x8013DB90:("func_8013DB90",), - 0x8013DC40:("func_8013DC40",), - 0x8013DCCC:("func_8013DCCC",), + 0x8013DB90:("SubS_IsFloorAbove",), + 0x8013DC40:("SubS_CopyPointFromPathList",), + 0x8013DCCC:("SubS_GetPathCount",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), @@ -9654,7 +9654,7 @@ 0x80A0EEC8:("EnSob1_UpdateItemSelectedProperty",), 0x80A0EF48:("EnSob1_UpdateCursorAnim",), 0x80A0F014:("EnSob1_UpdateStickDirectionPromptAnim",), - 0x80A0F1C4:("EnSob1_GetXZAngleAndDistanceSqToPoint",), + 0x80A0F1C4:("EnSob1_GetDistSqAndOrient",), 0x80A0F284:("EnSob1_GetCutscenes",), 0x80A0F2C8:("EnSob1_WaitForBlink",), 0x80A0F2FC:("EnSob1_Blink",), @@ -15211,7 +15211,7 @@ 0x80BAB434:("func_80BAB434",), 0x80BAB490:("EnSuttari_GetPaths",), 0x80BAB4F0:("func_80BAB4F0",), - 0x80BAB698:("func_80BAB698",), + 0x80BAB698:("EnSuttari_GetDistSqAndOrient",), 0x80BAB758:("func_80BAB758",), 0x80BAB8F4:("func_80BAB8F4",), 0x80BABA90:("func_80BABA90",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 78ac67dba2..7ead89bddc 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2181,14 +2181,14 @@ asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF -asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 -asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 -asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 +asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 +asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 -asm/non_matchings/code/z_sub_s/func_8013C8B8.s,func_8013C8B8,0x8013C8B8,0x2B +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 @@ -2196,18 +2196,18 @@ asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 -asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 -asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 -asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 -asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 -asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 +asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPoints.s,SubS_GetDistSqAndOrientPoints,0x8013D720,0x12 +asm/non_matchings/code/z_sub_s/SubS_MoveActorToPoint.s,SubS_MoveActorToPoint,0x8013D768,0x35 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPath.s,SubS_GetDistSqAndOrientPath,0x8013D83C,0x28 asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 -asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C -asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 +asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46