Quake & Distortion Docs (Again) + Math Cleanup (Camera Prep) (#1129)

* more quake docs

* more docs

* more distortion docs

* math cleanup

* fix header

* cleanup

* only partial PR review

* PR Suggestions

* fix master merge

* reverb angle change macros

* more revert

* fix enum
This commit is contained in:
engineer124
2023-05-19 00:29:50 +10:00
committed by GitHub
parent 83ac58d739
commit 180227e7bb
62 changed files with 811 additions and 729 deletions
+20 -20
View File
@@ -119,23 +119,23 @@ u8 CutsceneCamera_ProcessSpline(CutsceneCamera* csCamera) {
switch (csCamera->atCmd[csCamera->eyeInterp.curPoint].relativeTo) {
case CS_CAM_REL_2:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 2);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF);
break;
case CS_CAM_REL_3:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_1:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_4:
OLib_DbCameraVec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_5:
OLib_DbCameraVec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, 2);
OLib_Vec3fDiff(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_DIFF);
break;
default: // CS_CAM_REL_0
@@ -147,24 +147,24 @@ u8 CutsceneCamera_ProcessSpline(CutsceneCamera* csCamera) {
switch (csCamera->atCmd[csCamera->eyeInterp.curPoint].relativeTo) {
case CS_CAM_REL_2:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 2);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD);
break;
case CS_CAM_REL_3:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET);
csCamera->camera->at.y += func_80163660(&player->actor);
break;
case CS_CAM_REL_1:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET);
break;
case CS_CAM_REL_4:
OLib_DbCameraVec3fSum(&target->world, &csCamera->camera->at, &csCamera->camera->at, 1);
OLib_Vec3fAdd(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD_OFFSET);
break;
case CS_CAM_REL_5:
OLib_DbCameraVec3fSum(&target->world, &csCamera->camera->at, &csCamera->camera->at, 2);
OLib_Vec3fAdd(&target->world, &csCamera->camera->at, &csCamera->camera->at, OLIB_ADD);
break;
default: // CS_CAM_REL_0
@@ -189,23 +189,23 @@ u8 CutsceneCamera_ProcessSpline(CutsceneCamera* csCamera) {
switch (csCamera->eyeCmd[csCamera->atInterp.curPoint].relativeTo) {
case CS_CAM_REL_2:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 2);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF);
break;
case CS_CAM_REL_3:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_1:
OLib_DbCameraVec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fDiff(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_4:
OLib_DbCameraVec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF_OFFSET);
break;
case CS_CAM_REL_5:
OLib_DbCameraVec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, 2);
OLib_Vec3fDiff(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_DIFF);
break;
default: // CS_CAM_REL_0
@@ -217,24 +217,24 @@ u8 CutsceneCamera_ProcessSpline(CutsceneCamera* csCamera) {
switch (csCamera->eyeCmd[csCamera->atInterp.curPoint].relativeTo) {
case CS_CAM_REL_2:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 2);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD);
break;
case CS_CAM_REL_3:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET);
csCamera->camera->eye.y += func_80163660(&player->actor);
break;
case CS_CAM_REL_1:
OLib_DbCameraVec3fSum(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fAdd(&player->actor.world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET);
break;
case CS_CAM_REL_4:
OLib_DbCameraVec3fSum(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, 1);
OLib_Vec3fAdd(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD_OFFSET);
break;
case CS_CAM_REL_5:
OLib_DbCameraVec3fSum(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, 2);
OLib_Vec3fAdd(&target->world, &csCamera->camera->eye, &csCamera->camera->eye, OLIB_ADD);
break;
default: // CS_CAM_REL_0
+12 -13
View File
@@ -2574,7 +2574,7 @@ void Actor_Draw(PlayState* play, Actor* actor) {
(actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, play);
Lights_Draw(light, play->state.gfxCtx);
if (actor->flags & ACTOR_FLAG_1000) {
if (actor->flags & ACTOR_FLAG_IGNORE_QUAKE) {
Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.quakeOffset.x,
actor->world.pos.y +
((actor->shape.yOffset * actor->scale.y) + play->mainCamera.quakeOffset.y),
@@ -3791,30 +3791,29 @@ void func_800BC620(Vec3f* pos, Vec3f* scale, u8 alpha, PlayState* play) {
CLOSE_DISPS(play->state.gfxCtx);
}
void Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown) {
s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3);
void Actor_RequestQuake(PlayState* play, s16 y, s16 duration) {
s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0);
Quake_SetCountdown(quakeIndex, countdown);
Quake_SetPerturbations(quakeIndex, y, 0, 0, 0);
Quake_SetDuration(quakeIndex, duration);
}
void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed) {
s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3);
void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed) {
s16 quakeIndex = Quake_Request(&play->mainCamera, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, speed);
Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0);
Quake_SetCountdown(quakeIndex, countdown);
Quake_SetPerturbations(quakeIndex, y, 0, 0, 0);
Quake_SetDuration(quakeIndex, duration);
}
// Actor_RequestRumble?
void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) {
if (y >= 5) {
void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration) {
if (quakeY >= 5) {
Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150);
} else {
Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100);
}
Actor_AddQuake(play, y, countdown);
Actor_RequestQuake(play, quakeY, quakeDuration);
}
typedef struct {
+2 -2
View File
@@ -699,7 +699,7 @@ f32 D_801B9E60 = 0.0f;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo1.s")
// Data for opening chests (default)
VecSph D_801B9E64[] = {
VecGeo D_801B9E64[] = {
{ 50.0f, 0xEE3A, 0xD558 },
{ 75.0f, 0x0000, 0x8008 },
{ 80.0f, 0xEE3A, 0x8008 },
@@ -713,7 +713,7 @@ Vec3f D_801B9E84[] = {
};
// Data for opening chests (goron)
VecSph D_801B9EB4[] = {
VecGeo D_801B9EB4[] = {
{ 60.0f, 0xEE3A, 0xD558 },
{ 95.0f, 0x0000, 0x8008 },
{ 90.0f, 0xEE3A, 0x8008 },
+2 -2
View File
@@ -3795,12 +3795,12 @@ s32 sCameraHudVisibility = 2;
s32 sCameraLetterboxSize = 32;
s32 sCameraNegOne = -1;
// VecSph yaw data
// VecGeo yaw data
s16 D_801B9E18[] = {
0x0AAA, 0xF556, 0x1555, 0xEAAB, 0x2AAA, 0xD556, 0x3FFF, 0xC001, 0x5555, 0xAAAB, 0x6AAA, 0x9556, 0x7FFF, 0x0000,
};
// VecSph pitch data
// VecGeo pitch data
s16 D_801B9E34[] = {
0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, 0xFD3A, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, 0xFA74, 0x0000,
};
+9 -9
View File
@@ -202,10 +202,10 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) {
case CS_MISC_EARTHQUAKE_MEDIUM:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG);
if (isFirstFrame) {
sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
Quake_SetSpeed(sCutsceneQuakeIndex, 22000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
Quake_SetPerturbations(sCutsceneQuakeIndex, 6, 4, 0, 0);
Quake_SetDuration(sCutsceneQuakeIndex, 800);
}
break;
@@ -310,10 +310,10 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) {
case CS_MISC_EARTHQUAKE_STRONG:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG);
if (isFirstFrame) {
sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
Quake_SetSpeed(sCutsceneQuakeIndex, 30000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
Quake_SetPerturbations(sCutsceneQuakeIndex, 20, 10, 0, 0);
Quake_SetDuration(sCutsceneQuakeIndex, 800);
}
break;
@@ -372,10 +372,10 @@ void CutsceneCmd_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdMisc* cmd) {
case CS_MISC_EARTHQUAKE_WEAK:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG);
if (isFirstFrame) {
sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
sCutsceneQuakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
Quake_SetSpeed(sCutsceneQuakeIndex, 22000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
Quake_SetPerturbations(sCutsceneQuakeIndex, 2, 1, 0, 0);
Quake_SetDuration(sCutsceneQuakeIndex, 800);
}
break;
+54 -50
View File
@@ -100,16 +100,16 @@ Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph) {
}
/**
* Takes the geographic point `sph` and converts it into a x,y,z position
* Takes the geographic point `geo` and converts it into a x,y,z position
*/
Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph) {
VecSph geo;
Vec3f* OLib_VecGeoToVec3f(Vec3f* dest, VecGeo* geo) {
VecSph sph;
geo.r = sph->r;
geo.pitch = 0x4000 - sph->pitch;
geo.yaw = sph->yaw;
sph.r = geo->r;
sph.pitch = 0x4000 - geo->pitch;
sph.yaw = geo->yaw;
return OLib_VecSphToVec3f(dest, &geo);
return OLib_VecSphToVec3f(dest, &sph);
}
/**
@@ -117,16 +117,16 @@ Vec3f* OLib_VecSphGeoToVec3f(Vec3f* dest, VecSph* sph) {
*/
VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) {
VecSph sph;
f32 distSquared = SQ(vec->x) + SQ(vec->z);
f32 dist = sqrtf(distSquared);
f32 distXZSq = SQ(vec->x) + SQ(vec->z);
f32 distXZ = sqrtf(distXZSq);
if ((dist == 0.0f) && (vec->y == 0.0f)) {
if ((distXZ == 0.0f) && (vec->y == 0.0f)) {
sph.pitch = 0;
} else {
sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(dist, vec->y)));
sph.pitch = CAM_DEG_TO_BINANG(RAD_TO_DEG(func_80086B30(distXZ, vec->y)));
}
sph.r = sqrtf(SQ(vec->y) + distSquared);
sph.r = sqrtf(SQ(vec->y) + distXZSq);
if ((vec->x == 0.0f) && (vec->z == 0.0f)) {
sph.yaw = 0;
} else {
@@ -141,7 +141,7 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) {
/**
* Takes the point `vec`, and converts it to a geographic coordinate
*/
VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec) {
VecGeo* OLib_Vec3fToVecGeo(VecGeo* dest, Vec3f* vec) {
VecSph sph;
OLib_Vec3fToVecSph(&sph, vec);
@@ -156,42 +156,42 @@ VecSph* OLib_Vec3fToVecSphGeo(VecSph* dest, Vec3f* vec) {
* Takes the differences of positions `a` and `b`, and converts them to spherical coordinates
*/
VecSph* OLib_Vec3fDiffToVecSph(VecSph* dest, Vec3f* a, Vec3f* b) {
Vec3f sph;
Vec3f diff;
sph.x = b->x - a->x;
sph.y = b->y - a->y;
sph.z = b->z - a->z;
diff.x = b->x - a->x;
diff.y = b->y - a->y;
diff.z = b->z - a->z;
return OLib_Vec3fToVecSph(dest, &sph);
return OLib_Vec3fToVecSph(dest, &diff);
}
/**
* Takes the difference of positions `a` and `b`, and converts them to geographic coordinates
*/
VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b) {
Vec3f sph;
VecGeo* OLib_Vec3fDiffToVecGeo(VecGeo* dest, Vec3f* a, Vec3f* b) {
Vec3f diff;
sph.x = b->x - a->x;
sph.y = b->y - a->y;
sph.z = b->z - a->z;
diff.x = b->x - a->x;
diff.y = b->y - a->y;
diff.z = b->z - a->z;
return OLib_Vec3fToVecSphGeo(dest, &sph);
return OLib_Vec3fToVecGeo(dest, &diff);
}
/**
* Takes the sum of positions `a` (x,y,z coordinates) and `sph` (geographic coordinates), result is in x,y,z position
* Takes the sum of positions `a` (x,y,z coordinates) and `geo` (geographic coordinates), result is in x,y,z position
* Identical to Quake_AddVec from OoT
*/
Vec3f* OLib_VecSphAddToVec3f(Vec3f* dest, Vec3f* a, VecSph* sph) {
Vec3f vec;
Vec3f* OLib_AddVecGeoToVec3f(Vec3f* dest, Vec3f* a, VecGeo* geo) {
Vec3f sum;
Vec3f b;
OLib_VecSphGeoToVec3f(&b, sph);
vec.x = a->x + b.x;
vec.y = a->y + b.y;
vec.z = a->z + b.z;
OLib_VecGeoToVec3f(&b, geo);
sum.x = a->x + b.x;
sum.y = a->y + b.y;
sum.z = a->z + b.z;
*dest = vec;
*dest = sum;
return dest;
}
@@ -248,46 +248,50 @@ Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b) {
}
/**
* Gets a x,y,z position diff depending on the dbCamera mode
* Gets a x,y,z position diff depending on the mode
*/
void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) {
VecSph sph;
void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) {
VecGeo geo;
switch (mode) {
case 1:
OLib_Vec3fDiffToVecSphGeo(&sph, &a->pos, b);
sph.yaw -= a->rot.y;
OLib_VecSphGeoToVec3f(dest, &sph);
case OLIB_DIFF_OFFSET:
OLib_Vec3fDiffToVecGeo(&geo, &a->pos, b);
geo.yaw -= a->rot.y;
OLib_VecGeoToVec3f(dest, &geo);
break;
case 2:
case OLIB_DIFF:
dest->x = b->x - a->pos.x;
dest->y = b->y - a->pos.y;
dest->z = b->z - a->pos.z;
break;
default:
default: // OLIB_DIFF_COPY
*dest = *b;
break;
}
}
/**
* Gets a x,y,z position sum depending on the dbCamera mode
* Gets a x,y,z position sum depending on the mode
*/
void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) {
VecSph sph;
void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode) {
VecGeo geo;
switch (mode) {
case 1:
OLib_Vec3fToVecSphGeo(&sph, b);
sph.yaw += a->rot.y;
OLib_VecSphAddToVec3f(dest, &a->pos, &sph);
case OLIB_ADD_OFFSET:
OLib_Vec3fToVecGeo(&geo, b);
geo.yaw += a->rot.y;
OLib_AddVecGeoToVec3f(dest, &a->pos, &geo);
break;
case 2:
case OLIB_ADD:
dest->x = a->pos.x + b->x;
dest->y = a->pos.y + b->y;
dest->z = a->pos.z + b->z;
break;
default:
default: // OLIB_ADD_COPY
*dest = *b;
break;
}
+14 -14
View File
@@ -507,39 +507,39 @@ void Play_UpdateWaterCamera(PlayState* this, Camera* camera) {
if (!sIsCameraUnderwater) {
Camera_SetFlags(camera, CAM_STATE_UNDERWATER);
sQuakeIndex = -1;
Distortion_SetType(DISTORTION_TYPE_UNDERWATER_ENTRY);
Distortion_SetCountdown(80);
Distortion_Request(DISTORTION_TYPE_UNDERWATER_ENTRY);
Distortion_SetDuration(80);
}
func_801A3EC0(0x20);
func_800F6834(this, lightIndex);
if ((sQuakeIndex == -1) || (Quake_GetCountdown(sQuakeIndex) == 10)) {
s16 quakeIndex = Quake_Add(camera, QUAKE_TYPE_5);
if ((sQuakeIndex == -1) || (Quake_GetTimeLeft(sQuakeIndex) == 10)) {
s16 quakeIndex = Quake_Request(camera, QUAKE_TYPE_5);
sQuakeIndex = quakeIndex;
if (quakeIndex != 0) {
Quake_SetSpeed(sQuakeIndex, 550);
Quake_SetQuakeValues(sQuakeIndex, 1, 1, 180, 0);
Quake_SetCountdown(sQuakeIndex, 1000);
Quake_SetPerturbations(sQuakeIndex, 1, 1, 180, 0);
Quake_SetDuration(sQuakeIndex, 1000);
}
}
if (player->stateFlags3 & PLAYER_STATE3_8000) {
Distortion_SetType(DISTORTION_TYPE_ZORA_SWIMMING);
Distortion_ClearType(DISTORTION_TYPE_NON_ZORA_SWIMMING);
Distortion_Request(DISTORTION_TYPE_ZORA_SWIMMING);
Distortion_RemoveRequest(DISTORTION_TYPE_NON_ZORA_SWIMMING);
} else {
Distortion_SetType(DISTORTION_TYPE_NON_ZORA_SWIMMING);
Distortion_ClearType(DISTORTION_TYPE_ZORA_SWIMMING);
Distortion_Request(DISTORTION_TYPE_NON_ZORA_SWIMMING);
Distortion_RemoveRequest(DISTORTION_TYPE_ZORA_SWIMMING);
}
} else {
if (sIsCameraUnderwater) {
Camera_ClearFlags(camera, CAM_STATE_UNDERWATER);
}
Distortion_ClearType(DISTORTION_TYPE_NON_ZORA_SWIMMING);
Distortion_ClearType(DISTORTION_TYPE_UNDERWATER_ENTRY);
Distortion_ClearType(DISTORTION_TYPE_ZORA_SWIMMING);
Distortion_RemoveRequest(DISTORTION_TYPE_NON_ZORA_SWIMMING);
Distortion_RemoveRequest(DISTORTION_TYPE_UNDERWATER_ENTRY);
Distortion_RemoveRequest(DISTORTION_TYPE_ZORA_SWIMMING);
if (sQuakeIndex != 0) {
Quake_Remove(sQuakeIndex);
Quake_RemoveRequest(sQuakeIndex);
}
func_800F694C(this);
func_801A3EC0(0);
+350 -304
View File
@@ -3,35 +3,28 @@
#include "z64view.h"
typedef struct {
/* 0x00 */ s16 randIndex;
/* 0x02 */ s16 countdownMax;
/* 0x00 */ s16 index;
/* 0x02 */ s16 duration;
/* 0x04 */ Camera* camera;
/* 0x08 */ u32 type;
/* 0x0C */ s16 verticalMag;
/* 0x0E */ s16 horizontalMag;
/* 0x10 */ s16 zoom;
/* 0x12 */ s16 rollOffset;
/* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane
/* 0x0C */ s16 y;
/* 0x0E */ s16 x;
/* 0x10 */ s16 fov;
/* 0x12 */ s16 upRollOffset;
/* 0x14 */ Vec3s orientation; // alters the orientation of the xy perturbation. Only x (pitch) and y (yaw) are used
/* 0x1A */ s16 speed;
/* 0x1C */ s16 isShakePerpendicular;
/* 0x1E */ s16 countdown;
/* 0x1C */ s16 isRelativeToScreen; // is the quake relative to the screen or on world coordinates
/* 0x1E */ s16 timer;
/* 0x20 */ s16 camId;
} QuakeRequest; // size = 0x24
typedef struct {
/* 0x0 */ PlayState* play;
/* 0x4 */ s32 type; // bitfield, highest set bit determines type
/* 0x8 */ s16 countdown;
/* 0x8 */ s16 timer;
/* 0xA */ s16 state;
} DistortionRequest; // size = 0xC
typedef struct {
/* 0x00 */ Vec3f atOffset;
/* 0x0C */ Vec3f eyeOffset;
/* 0x18 */ s16 rollOffset;
/* 0x1A */ s16 zoom;
} ShakeInfo; // size = 0x1C
typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*);
typedef enum {
@@ -40,230 +33,257 @@ typedef enum {
/* 2 */ DISTORTION_SETUP
} DistortionState;
QuakeRequest sQuakeRequest[4];
QuakeRequest sQuakeRequests[4];
DistortionRequest sDistortionRequest;
static s16 sIsQuakeInitialized = true;
static s16 sQuakeUnused = 1;
static s16 sQuakeRequestCount = 0;
f32 Quake_Random(void) {
return 2.0f * (Rand_ZeroOne() - 0.5f);
}
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation) {
void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 yOffset, f32 xOffset) {
Vec3f* at = &req->camera->at;
Vec3f* eye = &req->camera->eye;
Vec3f atEyeOffset;
VecSph atEyeOffsetSph2;
VecSph eyeAtAngle;
VecSph geo;
VecSph eyeToAtGeo;
// isShakePerpendicular is always set to 1 before reaching this conditional
// alternative is an unused fixed vertical shake
if (req->isShakePerpendicular) {
if (req->isRelativeToScreen) {
atEyeOffset.x = 0;
atEyeOffset.y = 0;
atEyeOffset.z = 0;
OLib_Vec3fDiffToVecSphGeo(&eyeAtAngle, eye, at);
OLib_Vec3fDiffToVecGeo(&eyeToAtGeo, eye, at);
atEyeOffsetSph2.r = req->verticalMag * verticalPertubation;
atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x + 0x4000;
atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
// y shake
geo.r = req->y * yOffset;
// point unit vector up, then add on `req->orientation`
geo.pitch = eyeToAtGeo.pitch + req->orientation.x + 0x4000;
geo.yaw = eyeToAtGeo.yaw + req->orientation.y;
// apply y shake
OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo);
atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation;
atEyeOffsetSph2.pitch = eyeAtAngle.pitch + req->shakePlaneOffset.x;
atEyeOffsetSph2.yaw = eyeAtAngle.yaw + req->shakePlaneOffset.y + 0x4000;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
// x shake
geo.r = req->x * xOffset;
// point unit vector left, then add on `req->orientation`
geo.pitch = eyeToAtGeo.pitch + req->orientation.x;
geo.yaw = eyeToAtGeo.yaw + req->orientation.y + 0x4000;
// apply x shake
OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo);
} else {
atEyeOffset.x = 0;
atEyeOffset.y = req->verticalMag * verticalPertubation;
atEyeOffset.y = req->y * yOffset;
atEyeOffset.z = 0;
atEyeOffsetSph2.r = req->horizontalMag * horizontalPertubation;
atEyeOffsetSph2.pitch = req->shakePlaneOffset.x;
atEyeOffsetSph2.yaw = req->shakePlaneOffset.y;
geo.r = req->x * xOffset;
geo.pitch = req->orientation.x;
geo.yaw = req->orientation.y;
OLib_VecSphAddToVec3f(&atEyeOffset, &atEyeOffset, &atEyeOffsetSph2);
OLib_AddVecGeoToVec3f(&atEyeOffset, &atEyeOffset, &geo);
}
shake->atOffset = shake->eyeOffset = atEyeOffset;
shake->rollOffset = req->rollOffset * verticalPertubation;
shake->zoom = req->zoom * verticalPertubation;
shake->upRollOffset = req->upRollOffset * yOffset;
shake->fovOffset = req->fov * yOffset;
}
s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
if (req->timer > 0) {
f32 xyOffset = Math_SinS(req->speed * req->timer);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset);
req->timer--;
}
return req->countdown;
return req->timer;
}
s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown);
if (req->timer > 0) {
f32 xyOffset = Math_SinS(req->speed * req->timer);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation);
req->countdown--;
Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset);
req->timer--;
}
return req->countdown;
return req->timer;
}
s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) {
f32 perpendicularPertubation;
f32 xyOffset;
req->countdown--;
perpendicularPertubation = Math_SinS(req->speed * ((req->countdown & 0xF) + 500));
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->timer--;
xyOffset = Math_SinS(req->speed * ((req->timer & 0xF) + 500));
Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset);
// Not returning the timer ensures quake type 6 continues indefinitely until manually removed
return 1;
}
s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation =
Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax);
if (req->timer > 0) {
f32 xyOffset = Math_SinS(req->speed * req->timer) * ((f32)req->timer / req->duration);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, perpendicularPertubation);
req->countdown--;
Quake_UpdateShakeInfo(req, shake, xyOffset, xyOffset);
req->timer--;
}
return req->countdown;
return req->timer;
}
s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random();
if (req->timer > 0) {
f32 xyOffset = Quake_Random();
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset);
req->timer--;
}
return req->countdown;
return req->timer;
}
s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax);
if (req->timer > 0) {
f32 xyOffset = Quake_Random() * ((f32)req->timer / req->duration);
Quake_UpdateShakeInfo(req, shake, perpendicularPertubation, Rand_ZeroOne() * perpendicularPertubation);
req->countdown--;
Quake_UpdateShakeInfo(req, shake, xyOffset, Rand_ZeroOne() * xyOffset);
req->timer--;
}
return req->countdown;
return req->timer;
}
s16 Quake_GetFreeIndex(void) {
s32 i;
s32 ret = 0;
s32 min = 0x10000;
s32 index = 0;
s32 timerMin = UINT16_MAX + 1; // timer is a short, so start with a value beyond its range
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
if (sQuakeRequest[i].type == 0) {
ret = i;
for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) {
if (sQuakeRequests[i].type == QUAKE_TYPE_NONE) {
index = i;
break;
}
if (sQuakeRequest[i].countdown < min) {
min = sQuakeRequest[i].countdown;
ret = i;
if (timerMin > sQuakeRequests[i].timer) {
timerMin = sQuakeRequests[i].timer;
index = i;
}
}
return ret;
return index;
}
QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) {
QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) {
s16 index = Quake_GetFreeIndex();
QuakeRequest* req = &sQuakeRequest[index];
QuakeRequest* req = &sQuakeRequests[index];
__osMemset(req, 0, sizeof(QuakeRequest));
req->camera = camera;
req->camId = camera->camId;
req->type = type;
req->isShakePerpendicular = true;
req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index;
req->isRelativeToScreen = true;
// Add a unique random identifier to the upper bits of the index
// The `~3` assumes there are only 4 requests
req->index = index + ((s16)(Rand_ZeroOne() * 0x10000) & ~3);
sQuakeRequestCount++;
return req;
}
void Quake_RemoveRequest(QuakeRequest* req) {
req->type = 0;
req->countdown = -1;
void Quake_Remove(QuakeRequest* req) {
req->type = QUAKE_TYPE_NONE;
req->timer = -1;
sQuakeRequestCount--;
}
QuakeRequest* Quake_GetRequest(s16 quakeIndex) {
QuakeRequest* req = &sQuakeRequest[quakeIndex & 3];
QuakeRequest* Quake_GetRequest(s16 index) {
QuakeRequest* req = &sQuakeRequests[index & 3];
if (req->type == 0) {
if (req->type == QUAKE_TYPE_NONE) {
return NULL;
}
if (quakeIndex != req->randIndex) {
if (index != req->index) {
return NULL;
}
return req;
}
u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
// valueType for Quake_SetValue()
#define QUAKE_SPEED (1 << 0)
#define QUAKE_Y_OFFSET (1 << 1)
#define QUAKE_X_OFFSET (1 << 2)
#define QUAKE_FOV (1 << 3)
#define QUAKE_ROLL (1 << 4)
#define QUAKE_ORIENTATION_PITCH (1 << 5)
#define QUAKE_ORIENTATION_YAW (1 << 6)
#define QUAKE_ORIENTATION_ROLL (1 << 7)
#define QUAKE_DURATION (1 << 8)
#define QUAKE_IS_RELATIVE_TO_SCREEN (1 << 9)
u32 Quake_SetValue(s16 index, s16 valueType, s16 value) {
QuakeRequest* req = Quake_GetRequest(index);
if (req == NULL) {
return false;
} else {
switch (valueType) {
case QUAKE_SPEED:
req->speed = value;
break;
case QUAKE_VERTICAL_MAG:
req->verticalMag = value;
break;
case QUAKE_HORIZONTAL_MAG:
req->horizontalMag = value;
break;
case QUAKE_ZOOM:
req->zoom = value;
break;
case QUAKE_ROLL_OFFSET:
req->rollOffset = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_X:
req->shakePlaneOffset.x = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_Y:
req->shakePlaneOffset.y = value;
break;
case QUAKE_SHAKE_PLANE_OFFSET_Z:
req->shakePlaneOffset.z = value;
break;
case QUAKE_COUNTDOWN:
req->countdown = value;
req->countdownMax = req->countdown;
break;
case QUAKE_IS_SHAKE_PERPENDICULAR:
req->isShakePerpendicular = value;
break;
default:
break;
}
return true;
}
switch (valueType) {
case QUAKE_SPEED:
req->speed = value;
break;
case QUAKE_Y_OFFSET:
req->y = value;
break;
case QUAKE_X_OFFSET:
req->x = value;
break;
case QUAKE_FOV:
req->fov = value;
break;
case QUAKE_ROLL:
req->upRollOffset = value;
break;
case QUAKE_ORIENTATION_PITCH:
req->orientation.x = value;
break;
case QUAKE_ORIENTATION_YAW:
req->orientation.y = value;
break;
case QUAKE_ORIENTATION_ROLL:
req->orientation.z = value;
break;
case QUAKE_DURATION:
req->timer = value;
req->duration = req->timer;
break;
case QUAKE_IS_RELATIVE_TO_SCREEN:
req->isRelativeToScreen = value;
break;
default:
break;
}
return true;
}
u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
/**
* @param index
* @param speed for periodic types only, the angular frequency of the sine wave (binang / frame)
* @return true if successfully applied, false if the request does not exist
*/
u32 Quake_SetSpeed(s16 index, s16 speed) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
req->speed = speed;
@@ -272,45 +292,67 @@ u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) {
return false;
}
u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
/**
* @param index quake request index to apply
* @param duration number of frames to apply the quake
* @return true if successfully applied, false if the request does not exist
*/
u32 Quake_SetDuration(s16 index, s16 duration) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
req->countdown = countdown;
req->countdownMax = req->countdown;
req->duration = req->timer = duration;
return true;
}
return false;
}
s16 Quake_GetCountdown(s16 quakeIndex) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
/**
* @param index quake request index to get
* @return number of frames until the quake is finished
*/
s16 Quake_GetTimeLeft(s16 index) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
return req->countdown;
return req->timer;
}
return 0;
}
u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
/**
* @param index quake request index to apply
* @param y apply up/down shake
* @param x apply left/right shake
* @param fov apply zooming in/out shake (binang)
* @param roll apply rolling shake (binang)
* @return true if successfully applied, false if the request does not exist
*/
u32 Quake_SetPerturbations(s16 index, s16 y, s16 x, s16 fov, s16 roll) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
req->verticalMag = verticalMag;
req->horizontalMag = horizontalMag;
req->zoom = zoom;
req->rollOffset = rollOffset;
req->y = y;
req->x = x;
req->fov = fov;
req->upRollOffset = roll;
return true;
}
return false;
}
u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) {
QuakeRequest* req = Quake_GetRequest(quakeIndex);
/**
* @param index quake request index to apply
* @param isRelativeToScreen is the quake applied relative to the screen or in absolute world coordinates
* @param orientation orient the x/y shake to a different direction
* @return true if successfully applied, false if the request does not exist
*/
u32 Quake_SetOrientation(s16 index, s16 isRelativeToScreen, Vec3s orientation) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
req->isShakePerpendicular = isShakePerpendicular;
req->shakePlaneOffset = shakePlaneOffset;
req->isRelativeToScreen = isRelativeToScreen;
req->orientation = orientation;
return true;
}
return false;
@@ -319,156 +361,167 @@ u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakeP
void Quake_Init(void) {
s16 i;
for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) {
sQuakeRequest[i].type = 0;
sQuakeRequest[i].countdown = 0;
for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) {
sQuakeRequests[i].type = QUAKE_TYPE_NONE;
sQuakeRequests[i].timer = 0;
}
sIsQuakeInitialized = true;
sQuakeUnused = 1;
sQuakeRequestCount = 0;
}
s16 Quake_Add(Camera* camera, u32 type) {
return Quake_AddImpl(camera, type)->randIndex;
s16 Quake_Request(Camera* camera, u32 type) {
return Quake_RequestImpl(camera, type)->index;
}
u32 Quake_Remove(s16 index) {
u32 Quake_RemoveRequest(s16 index) {
QuakeRequest* req = Quake_GetRequest(index);
if (req != NULL) {
Quake_RemoveRequest(req);
Quake_Remove(req);
return true;
}
return false;
}
static QuakeCallbackFunc sQuakeCallbacks[] = {
NULL,
Quake_CallbackType1,
Quake_CallbackType2,
Quake_CallbackType3,
Quake_CallbackType4,
Quake_CallbackType5,
Quake_CallbackType6,
NULL, // QUAKE_TYPE_NONE
Quake_CallbackType1, // QUAKE_TYPE_1
Quake_CallbackType2, // QUAKE_TYPE_2
Quake_CallbackType3, // QUAKE_TYPE_3
Quake_CallbackType4, // QUAKE_TYPE_4
Quake_CallbackType5, // QUAKE_TYPE_5
Quake_CallbackType6, // QUAKE_TYPE_6
};
s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
s32 pad;
QuakeRequest* req;
ShakeInfo shake;
s16 Quake_Update(Camera* camera, ShakeInfo* camShake) {
f32 absSpeedDiv;
ShakeInfo shake;
QuakeRequest* req;
f32 maxCurr;
f32 maxNext;
s32 index;
s32 ret;
u32 eq;
Vec3f originVec;
s32 numQuakesApplied;
u32 isDifferentCamId;
Vec3f zeroVec;
PlayState* play = camera->play;
originVec.x = 0.0f;
originVec.y = 0.0f;
originVec.z = 0.0f;
camData->atOffset.x = 0.0f;
camData->atOffset.y = 0.0f;
camData->atOffset.z = 0.0f;
camData->eyeOffset.x = 0.0f;
camData->eyeOffset.y = 0.0f;
camData->eyeOffset.z = 0.0f;
camData->rollOffset = 0;
camData->zoom = 0;
camData->max = 0.0f;
zeroVec.x = 0.0f;
zeroVec.y = 0.0f;
zeroVec.z = 0.0f;
camShake->atOffset.x = 0.0f;
camShake->atOffset.y = 0.0f;
camShake->atOffset.z = 0.0f;
camShake->eyeOffset.x = 0.0f;
camShake->eyeOffset.y = 0.0f;
camShake->eyeOffset.z = 0.0f;
camShake->upRollOffset = 0;
camShake->fovOffset = 0;
camShake->maxOffset = 0.0f;
if (sQuakeRequestCount == 0) {
return 0;
}
ret = 0;
for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) {
req = &sQuakeRequest[index];
if (req->type != 0) {
if (play->cameraPtrs[req->camId] == NULL) {
Quake_RemoveRequest(req);
} else {
eq = (camera->camId != req->camera->camId);
absSpeedDiv = ABS(req->speed) / (f32)0x8000;
if (sQuakeCallbacks[req->type](req, &shake) == 0) {
Quake_RemoveRequest(req);
} else if (eq == 0) {
if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) {
camData->atOffset.x = shake.atOffset.x;
}
if (fabsf(camData->atOffset.y) < fabsf(shake.atOffset.y)) {
camData->atOffset.y = shake.atOffset.y;
}
if (fabsf(camData->atOffset.z) < fabsf(shake.atOffset.z)) {
camData->atOffset.z = shake.atOffset.z;
}
if (fabsf(camData->eyeOffset.x) < fabsf(shake.eyeOffset.x)) {
camData->eyeOffset.x = shake.eyeOffset.x;
}
if (fabsf(camData->eyeOffset.y) < fabsf(shake.eyeOffset.y)) {
camData->eyeOffset.y = shake.eyeOffset.y;
}
if (fabsf(camData->eyeOffset.z) < fabsf(shake.eyeOffset.z)) {
camData->eyeOffset.z = shake.eyeOffset.z;
}
if (camData->rollOffset < shake.rollOffset) {
camData->rollOffset = shake.rollOffset;
}
if (camData->zoom < shake.zoom) {
camData->zoom = shake.zoom;
}
maxCurr = OLib_Vec3fDist(&shake.atOffset, &originVec) * absSpeedDiv;
maxNext = OLib_Vec3fDist(&shake.eyeOffset, &originVec) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camData->rollOffset * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camData->zoom * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
if (camData->max < maxCurr) {
camData->max = maxCurr;
}
ret++;
}
}
numQuakesApplied = 0;
for (index = 0; index < ARRAY_COUNT(sQuakeRequests); index++) {
req = &sQuakeRequests[index];
if (req->type == QUAKE_TYPE_NONE) {
continue;
}
if (play->cameraPtrs[req->camId] == NULL) {
Quake_Remove(req);
continue;
}
isDifferentCamId = (camera->camId != req->camera->camId);
absSpeedDiv = (f32)ABS(req->speed) / 0x8000;
if (sQuakeCallbacks[req->type](req, &shake) == 0) {
// Quake has reached the end of its timer.
Quake_Remove(req);
continue;
}
if (isDifferentCamId) {
// Quake is attached to a different camId
continue;
}
if (fabsf(camShake->atOffset.x) < fabsf(shake.atOffset.x)) {
camShake->atOffset.x = shake.atOffset.x;
}
if (fabsf(camShake->atOffset.y) < fabsf(shake.atOffset.y)) {
camShake->atOffset.y = shake.atOffset.y;
}
if (fabsf(camShake->atOffset.z) < fabsf(shake.atOffset.z)) {
camShake->atOffset.z = shake.atOffset.z;
}
if (fabsf(camShake->eyeOffset.x) < fabsf(shake.eyeOffset.x)) {
camShake->eyeOffset.x = shake.eyeOffset.x;
}
if (fabsf(camShake->eyeOffset.y) < fabsf(shake.eyeOffset.y)) {
camShake->eyeOffset.y = shake.eyeOffset.y;
}
if (fabsf(camShake->eyeOffset.z) < fabsf(shake.eyeOffset.z)) {
camShake->eyeOffset.z = shake.eyeOffset.z;
}
if (camShake->upRollOffset < shake.upRollOffset) {
camShake->upRollOffset = shake.upRollOffset;
}
if (camShake->fovOffset < shake.fovOffset) {
camShake->fovOffset = shake.fovOffset;
}
maxCurr = OLib_Vec3fDist(&shake.atOffset, &zeroVec) * absSpeedDiv;
maxNext = OLib_Vec3fDist(&shake.eyeOffset, &zeroVec) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camShake->upRollOffset * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
maxNext = (camShake->fovOffset * (7.0f / 2500.0f)) * absSpeedDiv;
maxCurr = CLAMP_MIN(maxCurr, maxNext);
if (camShake->maxOffset < maxCurr) {
camShake->maxOffset = maxCurr;
}
numQuakesApplied++;
}
return ret;
return numQuakesApplied;
}
void Distortion_Init(PlayState* play) {
sDistortionRequest.play = play;
View_ClearDistortion(&play->view);
sDistortionRequest.type = 0;
sDistortionRequest.countdown = 0;
sDistortionRequest.timer = 0;
sDistortionRequest.state = DISTORTION_INACTIVE;
}
void Distortion_SetCountdown(s16 countdown) {
sDistortionRequest.countdown = countdown;
void Distortion_SetDuration(s16 duration) {
sDistortionRequest.timer = duration;
sDistortionRequest.state = DISTORTION_SETUP;
}
s16 Distortion_GetCountdown(void) {
return sDistortionRequest.countdown;
s16 Distortion_GetTimeLeft(void) {
return sDistortionRequest.timer;
}
s16 Distortion_GetType(void) {
return sDistortionRequest.type;
}
void Distortion_SetType(s32 type) {
void Distortion_Request(s32 type) {
if (sDistortionRequest.type < type) {
sDistortionRequest.type = type;
}
}
void Distortion_ClearType(s32 type) {
void Distortion_RemoveRequest(s32 type) {
if (sDistortionRequest.type == type) {
sDistortionRequest.type = 0;
}
@@ -489,7 +542,7 @@ ConveyorSpeed Distortion_GetUnderwaterCurrentSpeed(Player* player) {
void Distortion_Update(void) {
static s16 depthPhase = 0x3F0;
static s16 screenPlanePhase = 0x156;
static s16 countdownMax = 1;
static s16 duration = 1;
f32 xyScaleFactor;
f32 zScaleFactor;
f32 speedScaleFactor;
@@ -511,8 +564,8 @@ void Distortion_Update(void) {
f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f);
if (sDistortionRequest.type != 0) {
if (sDistortionRequest.type & DISTORTION_TYPE_B) {
sDistortionRequest.countdown = 2;
if (sDistortionRequest.type & DISTORTION_TYPE_MASK_TRANSFORM_2) {
sDistortionRequest.timer = 2;
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
@@ -528,17 +581,17 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.6f;
xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f;
xyScaleFactor = zScaleFactor = sDistortionRequest.timer / 60.0f;
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_A) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_BOSS_WARP) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
}
depthPhaseStep = 0.0f;
screenPlanePhaseStep = 50.0f / countdownMax;
screenPlanePhaseStep = 50.0f / duration;
rotX = 0.0f;
rotY = 0.0f;
@@ -549,11 +602,11 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.4f;
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration;
speedScaleFactor = 0.5f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_9) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_MASK_TRANSFORM_1) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x1FC;
screenPlanePhase = 0x156;
}
@@ -570,11 +623,11 @@ void Distortion_Update(void) {
zScale = 0.0f;
speed = 0.1f;
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration;
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_8) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_GORON_BUTT) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x2710;
screenPlanePhase = 0x3E8;
}
@@ -591,15 +644,15 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.5f;
if (sDistortionRequest.countdown < 5) {
xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax;
if (sDistortionRequest.timer < 5) {
xyScaleFactor = zScaleFactor = ((f32)duration - sDistortionRequest.timer) / (f32)duration;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_7) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_UNK_ATTACK) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x4B0;
screenPlanePhase = 0x7D0;
}
@@ -616,11 +669,11 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.5f;
xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax;
xyScaleFactor = zScaleFactor = sDistortionRequest.timer / (f32)duration;
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_6) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_ZORA_KICK) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x9C4;
screenPlanePhase = 0xBB8;
}
@@ -637,14 +690,14 @@ void Distortion_Update(void) {
zScale = 0.01f;
speed = 1.3f;
if (sDistortionRequest.countdown < 4) {
xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax;
if (sDistortionRequest.timer < 4) {
xyScaleFactor = zScaleFactor = sDistortionRequest.timer / (f32)duration;
} else {
xyScaleFactor = zScaleFactor = 0.0f;
}
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_5) {
sDistortionRequest.countdown = 2;
} else if (sDistortionRequest.type & DISTORTION_TYPE_SONG_OF_TIME) {
sDistortionRequest.timer = 2;
if (sDistortionRequest.state == DISTORTION_SETUP) {
depthPhase = 0x9C4;
screenPlanePhase = 0xBB8;
@@ -670,7 +723,7 @@ void Distortion_Update(void) {
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_UNDERWATER_ENTRY) {
if (sDistortionRequest.state == DISTORTION_SETUP) {
countdownMax = sDistortionRequest.countdown;
duration = sDistortionRequest.timer;
depthPhase = 0x760;
screenPlanePhase = 0x1BC;
}
@@ -687,14 +740,14 @@ void Distortion_Update(void) {
zScale = 0.2f;
speed = 0.25f;
countdownRatio = sDistortionRequest.countdown / (f32)countdownMax;
countdownRatio = sDistortionRequest.timer / (f32)duration;
zScaleFactor = xyScaleFactor = countdownRatio;
speedScaleFactor = 1.0f;
} else if (sDistortionRequest.type & DISTORTION_TYPE_ZORA_SWIMMING) {
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
sDistortionRequest.countdown = 2;
sDistortionRequest.timer = 2;
player = GET_PLAYER(play);
if (player != NULL) {
@@ -749,7 +802,7 @@ void Distortion_Update(void) {
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
sDistortionRequest.countdown = 2;
sDistortionRequest.timer = 2;
player = GET_PLAYER(play);
depthPhaseStep = 359.2f;
@@ -796,12 +849,12 @@ void Distortion_Update(void) {
xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f);
zScaleFactor = 0.9f - xyScaleFactor;
} else if (sDistortionRequest.type & DISTORTION_TYPE_0) {
} else if (sDistortionRequest.type & DISTORTION_TYPE_HOT_ROOM) {
// Gives a small mirage-like appearance
depthPhase = 0x3F0;
screenPlanePhase = 0x156;
sDistortionRequest.countdown = 2;
sDistortionRequest.timer = 2;
depthPhaseStep = 0.0f;
screenPlanePhaseStep = 150.0f;
@@ -840,32 +893,25 @@ void Distortion_Update(void) {
View_ClearDistortion(&play->view);
sDistortionRequest.state = DISTORTION_INACTIVE;
sDistortionRequest.countdown = 0;
sDistortionRequest.timer = 0;
}
if (sDistortionRequest.countdown != 0) {
sDistortionRequest.countdown--;
if (sDistortionRequest.countdown == 0) {
if (sDistortionRequest.timer != 0) {
sDistortionRequest.timer--;
if (sDistortionRequest.timer == 0) {
sDistortionRequest.type = 0;
}
}
}
s32 Quake_NumActiveQuakes(void) {
QuakeRequest* req = sQuakeRequest;
s32 Quake_GetNumActiveQuakes(void) {
s32 numActiveQuakes = 0;
s32 i;
if (req[0].type != 0) {
numActiveQuakes++;
}
if (req[1].type != 0) {
numActiveQuakes++;
}
if (req[2].type != 0) {
numActiveQuakes++;
}
if (req[3].type != 0) {
numActiveQuakes++;
for (i = 0; i < ARRAY_COUNT(sQuakeRequests); i++) {
if (sQuakeRequests[i].type != QUAKE_TYPE_NONE) {
numActiveQuakes++;
}
}
return numActiveQuakes;
@@ -522,10 +522,10 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct*
sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z;
Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150);
quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 12);
Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0);
Quake_SetDuration(quakeIndex, 12);
if (this->unk_179 <= 0) {
func_8019F128(NA_SE_EV_STONEDOOR_STOP);
@@ -537,7 +537,7 @@ void func_80A9C058(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct*
}
}
void func_80A9C18C(BgHakuginPost* this, PlayState* play) {
void BgHakuginPost_RequestQuakeAndRumble(BgHakuginPost* this, PlayState* play) {
s32 pad;
Player* player = GET_PLAYER(play);
Camera* activeCam = GET_ACTIVE_CAM(play);
@@ -547,10 +547,10 @@ void func_80A9C18C(BgHakuginPost* this, PlayState* play) {
this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z),
255, 20, 150);
quakeIndex = Quake_Add(activeCam, QUAKE_TYPE_3);
quakeIndex = Quake_Request(activeCam, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 17232);
Quake_SetQuakeValues(quakeIndex, 6, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 20);
Quake_SetPerturbations(quakeIndex, 6, 0, 0, 0);
Quake_SetDuration(quakeIndex, 20);
}
void func_80A9C228(BgHakuginPost* this, PlayState* play, BgHakuginPostUnkStruct* unkStruct) {
@@ -798,7 +798,7 @@ void func_80A9CD14(BgHakuginPost* this, PlayState* play) {
temp_f12 = CLAMP_MAX(temp_f12, 40.0f);
this->unk_16C += temp_f12;
if (this->unk_168 <= this->unk_16C) {
func_80A9C18C(this, play);
BgHakuginPost_RequestQuakeAndRumble(this, play);
func_8019F128(NA_SE_EV_STONEDOOR_STOP);
func_80A9CE00(this);
} else {
@@ -876,7 +876,7 @@ void func_80A9D0B4(BgHakuginPost* this, PlayState* play) {
func_80A9C634(this, play);
func_80A9B160(&D_80A9E028, play);
this->unk_16C = this->unk_164;
func_80A9C18C(this, play);
BgHakuginPost_RequestQuakeAndRumble(this, play);
func_8019F128(NA_SE_EV_STONEDOOR_STOP);
func_80A9CC84(this);
} else {
@@ -228,11 +228,11 @@ void BgIkanaDharma_Update(Actor* thisx, PlayState* play) {
Actor_MoveWithGravity(&this->dyna.actor);
Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4);
if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 21536);
Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 12);
Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0);
Quake_SetDuration(quakeIndex, 12);
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND);
}
@@ -832,11 +832,11 @@ void func_80B81A80(Actor* thisx, PlayState* play) {
func_80B81B84(this);
} else if (this->unk_584 == 15) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 31536);
Quake_SetQuakeValues(quakeIndex, 6, 0, 100, 0);
Quake_SetCountdown(quakeIndex, 22);
Quake_SetPerturbations(quakeIndex, 6, 0, 100, 0);
Quake_SetDuration(quakeIndex, 22);
}
}
@@ -859,11 +859,11 @@ void func_80B81BA0(Actor* thisx, PlayState* play) {
thisx->shape.rot.x += 0x1F4;
if (!(this->unk_584 & 7)) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 31536);
Quake_SetQuakeValues(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0);
Quake_SetCountdown(quakeIndex, 15);
Quake_SetPerturbations(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0);
Quake_SetDuration(quakeIndex, 15);
}
if (Flags_GetSwitch(play, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) {
@@ -929,11 +929,11 @@ void func_80B81DC8(Actor* thisx, PlayState* play) {
CutsceneManager_Stop(this->dyna.actor.csId);
func_80B818B4(this);
} else if (this->unk_584 == 19) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 5, 0, 40, 60);
Quake_SetCountdown(quakeIndex, 17);
Quake_SetPerturbations(quakeIndex, 5, 0, 40, 60);
Quake_SetDuration(quakeIndex, 17);
}
}
@@ -151,10 +151,10 @@ void func_80BD5A18(BgIkanaShutter* this, PlayState* play) {
this->dyna.actor.velocity.y *= 0.978f;
this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y;
if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) {
quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 21536);
Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 12);
Quake_SetPerturbations(quakeIndex, 4, 0, 0, 0);
Quake_SetDuration(quakeIndex, 12);
func_80BD5828(this);
}
@@ -69,19 +69,20 @@ void func_80C0A838(BgIkninSusceil* this, PlayState* play) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
}
void func_80C0A86C(BgIkninSusceil* this, PlayState* play, s16 verticalMag, s16 countdown, s32 arg4) {
void BgIkninSusceil_RequestQuakeAndRumble(BgIkninSusceil* this, PlayState* play, s16 quakeY, s16 quakeDuration,
s32 rumbleType) {
s32 pad;
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 31536);
Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0);
Quake_SetCountdown(quakeIndex, countdown);
Quake_SetPerturbations(quakeIndex, quakeY, 0, 0, 0);
Quake_SetDuration(quakeIndex, quakeDuration);
if (arg4 == 1) {
if (rumbleType == 1) {
Rumble_Request(SQ(100.0f), 255, 20, 150);
} else if (arg4 == 2) {
} else if (rumbleType == 2) {
Rumble_Request(SQ(100.0f), 180, 20, 100);
} else if (arg4 == 3) {
} else if (rumbleType == 3) {
Rumble_Request(SQ(100.0f), 120, 20, 10);
}
}
@@ -154,7 +155,7 @@ void func_80C0ABA8(BgIkninSusceil* this, PlayState* play) {
this->dyna.actor.velocity.y *= 0.93f;
this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y;
if (this->dyna.actor.world.pos.y <= this->dyna.actor.home.pos.y) {
func_80C0A86C(this, play, 4, 14, 1);
BgIkninSusceil_RequestQuakeAndRumble(this, play, 4, 14, 1);
Flags_UnsetSwitch(play, SUSCEIL_GET_SWITCHFLAG(&this->dyna.actor));
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND);
func_80C0AC74(this);
@@ -197,7 +198,7 @@ void func_80C0AD64(BgIkninSusceil* this, PlayState* play) {
this->dyna.actor.velocity.y *= 0.98f;
if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 365.0f, 0.5f,
this->dyna.actor.velocity.y, 1.0f) < 0.1f) {
func_80C0A86C(this, play, 1, 14, 3);
BgIkninSusceil_RequestQuakeAndRumble(this, play, 1, 14, 3);
CutsceneManager_Stop(this->dyna.actor.csId);
func_80C0AB14(this);
} else {
@@ -216,7 +217,7 @@ void func_80C0AE5C(BgIkninSusceil* this, PlayState* play) {
this->dyna.actor.velocity.y = CLAMP_MIN(this->dyna.actor.velocity.y, 1.0f);
this->dyna.actor.world.pos.y = this->dyna.actor.world.pos.y + this->dyna.actor.velocity.y;
if ((this->dyna.actor.home.pos.y + 365.0f) < this->dyna.actor.world.pos.y) {
func_80C0A86C(this, play, 3, 14, 2);
BgIkninSusceil_RequestQuakeAndRumble(this, play, 3, 14, 2);
func_80C0AB14(this);
}
}
@@ -151,10 +151,10 @@ void func_80ACAEF0(BgOpenShutter* this, PlayState* play) {
Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true);
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND);
quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, -32536);
Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 10);
Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0);
Quake_SetDuration(quakeIndex, 10);
Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100);
+2 -2
View File
@@ -1050,7 +1050,7 @@ void Boss03_Charge(Boss03* this, PlayState* play) {
// Attack platform
if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) {
play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION);
func_800BC848(&this->actor, play, 20, 15);
Actor_RequestQuakeAndRumble(&this->actor, play, 20, 15);
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, 0x96,
ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE);
@@ -1773,7 +1773,7 @@ void Boss03_Stunned(Boss03* this, PlayState* play) {
Actor_MoveWithGravity(&this->actor);
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
play_sound(NA_SE_IT_WALL_HIT_HARD);
func_800BC848(&this->actor, play, 10, 10);
Actor_RequestQuakeAndRumble(&this->actor, play, 10, 10);
}
} else {
Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900);
+1 -1
View File
@@ -481,7 +481,7 @@ void func_809ECF58(Boss04* this, PlayState* play) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) {
play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION);
func_800BC848(&this->actor, play, 15, 10);
Actor_RequestQuakeAndRumble(&this->actor, play, 15, 10);
this->unk_6F4 = 15;
sp3C.x = this->actor.focus.pos.x;
sp3C.y = this->actor.focus.pos.y;
@@ -610,10 +610,10 @@ void func_808A1B48(DoorShutter* this, PlayState* play) {
}
Actor_PlaySfx(&this->actor, NA_SE_EV_BIGWALL_BOUND);
quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, -32536);
Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 10);
Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0);
Quake_SetDuration(quakeIndex, 10);
Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100);
+3 -3
View File
@@ -220,10 +220,10 @@ void EnAni_FallToGround(EnAni* this, PlayState* play) {
Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f);
this->stateFlags |= ANI_STATE_WRITHING;
quakeIndex = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3);
quakeIndex = Quake_Request(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 27000);
Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 20);
Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0);
Quake_SetDuration(quakeIndex, 20);
Actor_PlaySfx(&this->actor, NA_SE_IT_HAMMER_HIT);
}
+1 -1
View File
@@ -7,7 +7,7 @@
#include "z_en_bat.h"
#include "objects/object_bat/object_bat.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000)
#define THIS ((EnBat*)thisx)
@@ -540,13 +540,13 @@ void func_80A287E8(EnBigpamet* this, PlayState* play) {
}
if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) {
quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
this->actor.velocity.y = this->unk_29E * 0.375f;
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 10);
Quake_SetPerturbations(quakeIndex, 15, 0, 0, 0);
Quake_SetDuration(quakeIndex, 10);
Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100);
@@ -8,7 +8,7 @@
#include "objects/object_bigpo/object_bigpo.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_1000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE)
#define THIS ((EnBigpo*)thisx)
@@ -742,11 +742,11 @@ void EnBigslime_EndThrowMinislime(EnBigslime* this) {
void EnBigslime_BreakIntoMinislime(EnBigslime* this, PlayState* play) {
s32 i;
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 15);
Quake_SetPerturbations(quakeIndex, 15, 0, 0, 0);
Quake_SetDuration(quakeIndex, 15);
Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100);
+4 -3
View File
@@ -423,8 +423,8 @@ void EnBom_Explode(EnBom* this, PlayState* play) {
}
}
static s16 D_80872E98[] = { 3, 5 };
static s16 D_80872E9C[] = { 10, 15 };
static s16 sQuakeY[] = { 3, 5 };
static s16 sQuakeDurations[] = { 10, 15 };
void EnBom_Update(Actor* thisx, PlayState* play) {
Vec3f effVelocity = { 0.0f, 0.0f, 0.0f };
@@ -545,7 +545,8 @@ void EnBom_Update(Actor* thisx, PlayState* play) {
}
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, effPos.x, effPos.y - 10.0f, effPos.z, 0, 0, 0,
this->isPowderKeg);
func_800BC848(thisx, play, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]);
Actor_RequestQuakeAndRumble(thisx, play, sQuakeY[this->isPowderKeg],
sQuakeDurations[this->isPowderKeg]);
play->envCtx.lightSettings.diffuseColor1[0] = play->envCtx.lightSettings.diffuseColor1[1] =
play->envCtx.lightSettings.diffuseColor1[2] = 250;
play->envCtx.lightSettings.ambientColor[0] = play->envCtx.lightSettings.ambientColor[1] =
+1 -1
View File
@@ -6,7 +6,7 @@
#include "z_en_crow.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000)
#define THIS ((EnCrow*)thisx)
@@ -7,7 +7,7 @@
#include "z_en_death.h"
#include "z64rumble.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_IGNORE_QUAKE)
#define THIS ((EnDeath*)thisx)
+23 -23
View File
@@ -328,19 +328,19 @@ void EnEgol_FootstepEffects(EnEgol* this, PlayState* play, f32 leftFootFrame, f3
if (Animation_OnFrame(&this->skelAnime, leftFootFrame) || Animation_OnFrame(&this->skelAnime, rightFootFrame)) {
Vec3f spawnPos;
Player* player = GET_PLAYER(play);
s32 quakeSize;
s32 quakeYOffset;
s32 pad;
Actor_PlaySfx(&this->actor, NA_SE_EN_EYEGOLE_WALK);
quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f);
if (quakeSize > 4) {
quakeSize = 4;
} else if (quakeSize < 1) {
quakeSize = 1;
quakeYOffset = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f);
if (quakeYOffset > 4) {
quakeYOffset = 4;
} else if (quakeYOffset < 1) {
quakeYOffset = 1;
}
if (player->stateFlags3 != PLAYER_STATE3_1000000) {
func_800BC848(&this->actor, play, quakeSize, 2);
Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2);
}
if (Animation_OnFrame(&this->skelAnime, leftFootFrame)) {
Math_Vec3f_Copy(&spawnPos, &this->leftFootPos);
@@ -755,7 +755,7 @@ void EnEgol_Laser(EnEgol* this, PlayState* play) {
f32 nz;
s32 pad3;
s32 i;
s32 quakeSize;
s32 quakeYOffset;
Player* player = GET_PLAYER(play);
nx = COLPOLY_GET_NORMAL(colPoly->normal.x);
@@ -773,14 +773,14 @@ void EnEgol_Laser(EnEgol* this, PlayState* play) {
if ((this->actor.world.pos.y - 50.0f) <= player->actor.world.pos.y) {
EnEgol_SpawnEffect(this, &hitPos, &rotToNorm, 100, 0.02f, EYEGORE_EFFECT_IMPACT);
}
quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f);
if (quakeSize > 4) {
quakeSize = 4;
} else if (quakeSize < 1) {
quakeSize = 1;
quakeYOffset = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f);
if (quakeYOffset > 4) {
quakeYOffset = 4;
} else if (quakeYOffset < 1) {
quakeYOffset = 1;
}
if (player->stateFlags3 != PLAYER_STATE3_1000000) {
func_800BC848(&this->actor, play, quakeSize, 2);
Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2);
}
Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION);
func_800B31BC(play, &hitPos, 40, -2, 255, 20);
@@ -880,16 +880,16 @@ void EnEgol_Slam(EnEgol* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Vec3f spawnPos;
f32 dyToPlayer = fabsf(player->actor.world.pos.y - this->actor.world.pos.y);
s32 quakeSize;
s32 quakeYOffset;
Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION);
quakeSize = 4 - (s32)(dyToPlayer * 0.02f);
if (quakeSize > 4) {
quakeSize = 4;
} else if (quakeSize < 1) {
quakeSize = 1;
quakeYOffset = 4 - (s32)(dyToPlayer * 0.02f);
if (quakeYOffset > 4) {
quakeYOffset = 4;
} else if (quakeYOffset < 1) {
quakeYOffset = 1;
}
func_800BC848(&this->actor, play, quakeSize, 2);
Actor_RequestQuakeAndRumble(&this->actor, play, quakeYOffset, 2);
if (this->actor.floorBgId == BGCHECK_SCENE) {
Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos);
spawnPos.x += Math_SinS(this->actor.world.rot.y) * 60.0f;
@@ -1064,7 +1064,7 @@ void EnEgol_Death(EnEgol* this, PlayState* play) {
this->subCamAt.y = 60.0f;
this->subCamAt.z = 260.0f;
Math_Vec3f_Copy(&atOffset, &this->subCamAt);
OLib_DbCameraVec3fSum(&this->actor.world, &atOffset, &this->subCamAt, 1);
OLib_Vec3fAdd(&this->actor.world, &atOffset, &this->subCamAt, OLIB_ADD_OFFSET);
this->subCamEye.x = this->actor.world.pos.x;
this->subCamEye.y = this->actor.world.pos.y + 70.0f;
this->subCamEye.z = this->actor.world.pos.z;
@@ -1080,7 +1080,7 @@ void EnEgol_Death(EnEgol* this, PlayState* play) {
} else {
if (Animation_OnFrame(&this->skelAnime, 46.0f)) {
Actor_PlaySfx(&this->actor, NA_SE_EV_EXPLOSION);
func_800BC848(&this->actor, play, 10, 5);
Actor_RequestQuakeAndRumble(&this->actor, play, 10, 5);
}
if ((curFrame >= this->animEndFrame) && (this->action != EYEGORE_ACTION_DEAD)) {
s32 i;
@@ -8,7 +8,7 @@
#include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h"
#include "objects/object_firefly/object_firefly.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000)
#define THIS ((EnFirefly*)thisx)
@@ -6,7 +6,7 @@
#include "z_en_firefly2.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000)
#define THIS ((EnFirefly2*)thisx)
+5 -5
View File
@@ -1046,16 +1046,16 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) {
return ret;
}
void func_80A136B8(PlayState* play, s16 speed, s16 verticalMag, s16 countdown) {
s16 quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
void EnGo_RequestQuake(PlayState* play, s16 speed, s16 y, s16 duration) {
s16 quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3);
Quake_SetCountdown(quakeIndex, countdown);
Quake_SetDuration(quakeIndex, duration);
Quake_SetSpeed(quakeIndex, speed);
Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0);
Quake_SetPerturbations(quakeIndex, y, 0, 0, 0);
}
void func_80A13728(EnGo* this, PlayState* play) {
func_80A136B8(play, 27767, 7, 20);
EnGo_RequestQuake(play, 27767, 7, 20);
play->actorCtx.unk2 = 4;
Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y,
this->actor.world.pos.z, 0, 0, 0, 0);
@@ -451,11 +451,11 @@ s32 func_8093F6F8(EnGoroiwa* this, PlayState* play) {
if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y <= sp7C)) {
if (this->unk_1CA == 0) {
if (this->actor.xzDistToPlayer < 400.0f) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 17232);
Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 7);
Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0);
Quake_SetDuration(quakeIndex, 7);
}
this->unk_1C4 = 0.0f;
+20 -20
View File
@@ -523,8 +523,8 @@ s32 func_80998A48(EnGs* this, PlayState* play) {
this->unk_1D4 = 0;
this->unk_19A |= 1;
this->unk_21C = 5;
this->unk_21E = 40;
this->quakeY = 5;
this->quakeDuration = 40;
this->unk_197++;
this->unk_197 &= 0xF;
this->unk_19D = 1;
@@ -558,8 +558,8 @@ s32 func_80998BBC(EnGs* this, PlayState* play) {
this->unk_1D4 = 0;
this->unk_19A |= 1;
this->unk_21C = 5;
this->unk_21E = 40;
this->quakeY = 5;
this->quakeDuration = 40;
this->unk_197--;
this->unk_197 &= 0xF;
this->unk_19D = 1;
@@ -585,8 +585,8 @@ s32 func_80998D44(EnGs* this, PlayState* play) {
this->unk_1E0 = -0.8f;
Actor_PlaySfx(&this->actor, NA_SE_EV_G_STONE_CRUSH);
this->unk_19A |= 1;
this->unk_21C = 40;
this->unk_21E = 11;
this->quakeY = 40;
this->quakeDuration = 11;
this->unk_19D++;
} else if (this->unk_19D == 1) {
step = Math_SmoothStepToF(&this->unk_1DC, this->unk_1E0, 1.0f, 0.4f, 0.001f);
@@ -611,8 +611,8 @@ s32 func_80998D44(EnGs* this, PlayState* play) {
this->unk_216 = 0;
this->unk_1E0 = 0.0f;
this->unk_1D4 = 0;
this->unk_21C = 10;
this->unk_21E = 10;
this->quakeY = 10;
this->quakeDuration = 10;
this->unk_1DC = 0.5f;
Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK);
this->unk_19D += 1;
@@ -641,8 +641,8 @@ s32 func_80998F9C(EnGs* this, PlayState* play) {
this->unk_1EC = 0.0f;
this->unk_19D = 1;
this->unk_21C = 2;
this->unk_21E = 40;
this->quakeY = 2;
this->quakeDuration = 40;
this->unk_216 = 200;
}
@@ -714,8 +714,8 @@ s32 func_80998F9C(EnGs* this, PlayState* play) {
this->unk_1F0 = 0.0f;
this->unk_1EC = 0.5f;
Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_ATTACK);
this->unk_21C = 20;
this->unk_21E = 2;
this->quakeY = 20;
this->quakeDuration = 2;
this->unk_19D = 6;
}
}
@@ -800,8 +800,8 @@ s32 func_809995A4(EnGs* this, PlayState* play) {
if (this->unk_1D4 <= 0) {
this->unk_19A &= ~4;
this->unk_21C = 3;
this->unk_21E = 40;
this->quakeY = 3;
this->quakeDuration = 40;
this->unk_1D4 = 0;
this->unk_19D++;
}
@@ -834,8 +834,8 @@ s32 func_809995A4(EnGs* this, PlayState* play) {
this->unk_1DC = 0.0f;
this->unk_19D++;
this->unk_21C = 5;
this->unk_21E = 20;
this->quakeY = 5;
this->quakeDuration = 20;
this->unk_19A |= 1;
this->unk_216 = 200;
this->unk_1E0 = (this->unk_197 >> 2) * 0x444;
@@ -1028,8 +1028,8 @@ void EnGs_Update(Actor* thisx, PlayState* play) {
if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > SCREEN_WIDTH) || (sp2C < 0) ||
(sp2C > SCREEN_HEIGHT)) {
this->unk_216 = 0;
} else if (this->unk_21C > 0) {
func_800BC848(&this->actor, play, this->unk_21C, this->unk_21E);
} else if (this->quakeY > 0) {
Actor_RequestQuakeAndRumble(&this->actor, play, this->quakeY, this->quakeDuration);
}
} else {
this->unk_216 = 0;
@@ -1048,8 +1048,8 @@ void EnGs_Update(Actor* thisx, PlayState* play) {
}
}
if (this->unk_21C > 0) {
this->unk_21C = 0;
if (this->quakeY > 0) {
this->quakeY = 0;
}
func_80999B34(this);
+2 -2
View File
@@ -53,8 +53,8 @@ typedef struct EnGs {
/* 0x216 */ s16 unk_216;
/* 0x218 */ s16 unk_218;
/* 0x21A */ s16 unk_21A;
/* 0x21C */ s16 unk_21C;
/* 0x21E */ s16 unk_21E;
/* 0x21C */ s16 quakeY;
/* 0x21E */ s16 quakeDuration;
} EnGs; // size = 0x220
#endif // Z_EN_GS_H
+3 -3
View File
@@ -597,11 +597,11 @@ void func_8095EBDC(EnIshi* this, PlayState* play) {
}
if (sp70 == 1) {
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 17232);
Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 7);
Quake_SetPerturbations(quakeIndex, 3, 0, 0, 0);
Quake_SetDuration(quakeIndex, 7);
Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150);
}
@@ -609,7 +609,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, PlayState* play) {
this->subCamEyeNext.z = D_80971DCC[this->unk190].z;
Math_Vec3f_Copy(&tempVec, &this->subCamEyeNext);
OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempVec, &this->subCamEyeNext, 1);
OLib_Vec3fAdd(&this->picto.actor.home, &tempVec, &this->subCamEyeNext, OLIB_ADD_OFFSET);
Math_Vec3f_Copy(&this->subCamAtNext, &this->unk22C);
Math_Vec3f_Copy(&this->subCamEye, &this->subCamEyeNext);
Math_Vec3f_Copy(&this->subCamAt, &this->subCamAtNext);
@@ -722,7 +722,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, PlayState* play) {
this->subCamEyeNext.y = D_80971FA0[this->unk190].y;
this->subCamEyeNext.z = D_80971FA0[this->unk190].z;
Math_Vec3f_Copy(&vec3fCopy, &this->subCamEyeNext);
OLib_DbCameraVec3fSum(&this->picto.actor.home, &vec3fCopy, &this->subCamEyeNext, 1);
OLib_Vec3fAdd(&this->picto.actor.home, &vec3fCopy, &this->subCamEyeNext, OLIB_ADD_OFFSET);
this->subCamAtNext.x = D_80971FE8[this->unk190].x + this->unk22C.x;
this->subCamAtNext.y = D_80971FE8[this->unk190].y + this->unk22C.y;
this->subCamAtNext.z = D_80971FE8[this->unk190].z + this->unk22C.z;
@@ -831,7 +831,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, PlayState* play) {
this->subCamEyeNext.y = D_80971E38[this->unk190].y;
this->subCamEyeNext.z = D_80971E38[this->unk190].z;
Math_Vec3f_Copy(&localVec3f, &this->subCamEyeNext);
OLib_DbCameraVec3fSum(&this->picto.actor.home, &localVec3f, &this->subCamEyeNext, 1);
OLib_Vec3fAdd(&this->picto.actor.home, &localVec3f, &this->subCamEyeNext, OLIB_ADD_OFFSET);
if (1) {}
this->subCamAtNext.x = D_80971EEC[this->unk190].x + this->unk22C.x;
@@ -978,7 +978,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, PlayState* play) {
this->subCamEyeNext.z = D_80972030.z;
Math_Vec3f_Copy(&tempunk238, &this->subCamEyeNext);
OLib_DbCameraVec3fSum(&this->picto.actor.home, &tempunk238, &this->subCamEyeNext, 1);
OLib_Vec3fAdd(&this->picto.actor.home, &tempunk238, &this->subCamEyeNext, OLIB_ADD_OFFSET);
this->subCamAtNext.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req
this->subCamAtNext.y = ((f32)D_8097203C.y) + this->unk22C.y;
this->subCamAtNext.z = ((f32)D_8097203C.z) + this->unk22C.z;
@@ -174,20 +174,20 @@ void EnMinislime_CheckBackgroundCollision(EnMinislime* this) {
}
void EnMinislime_AddIceShardEffect(EnMinislime* this) {
s32 pad;
EnBigslime* bigslime = (EnBigslime*)this->actor.parent;
EnBigslimeIceShardEffect* iceShardEffect;
s32 i = 10 * this->id + BIGSLIME_NUM_VTX;
s32 i_end = i + 10;
VecSph vecSph;
vecSph.yaw = 0;
s16 pitch;
s16 yaw = 0;
for (; i < i_end; i++) {
iceShardEffect = &bigslime->iceShardEffect[i];
vecSph.pitch = Rand_S16Offset(0x1000, 0x3000);
iceShardEffect->velocity.x = Math_CosS(vecSph.pitch) * Math_SinS(vecSph.yaw);
iceShardEffect->velocity.y = Math_SinS(vecSph.pitch);
iceShardEffect->velocity.z = Math_CosS(vecSph.pitch) * Math_CosS(vecSph.yaw);
pitch = Rand_S16Offset(0x1000, 0x3000);
iceShardEffect->velocity.x = Math_CosS(pitch) * Math_SinS(yaw);
iceShardEffect->velocity.y = Math_SinS(pitch);
iceShardEffect->velocity.z = Math_CosS(pitch) * Math_CosS(yaw);
iceShardEffect->pos.x = this->actor.world.pos.x + (400.0f * this->actor.scale.x) * iceShardEffect->velocity.x;
iceShardEffect->pos.y =
this->actor.world.pos.y + (((iceShardEffect->velocity.y * 2.0f) - 1.0f) * 400.0f * this->actor.scale.y);
@@ -198,7 +198,7 @@ void EnMinislime_AddIceShardEffect(EnMinislime* this) {
iceShardEffect->isEnabled = true;
Math_Vec3f_ScaleAndStore(&iceShardEffect->velocity, Rand_ZeroFloat(3.0f) + 7.0f, &iceShardEffect->velocity);
iceShardEffect->scale = (Rand_ZeroFloat(6.0f) + 2.0f) * 0.001f;
vecSph.yaw += 0x1999;
yaw += 0x1999;
}
this->frozenAlpha = 0;
@@ -1224,10 +1224,10 @@ void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, PlayState* play) {
// Zooms in on Snapper spawn point
Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye);
this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
this->quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_6);
Quake_SetSpeed(this->quakeIndex, 18000);
Quake_SetQuakeValues(this->quakeIndex, 2, 0, 0, 0);
Quake_SetCountdown(this->quakeIndex, 15);
Quake_SetPerturbations(this->quakeIndex, 2, 0, 0, 0);
Quake_SetDuration(this->quakeIndex, 15);
Rumble_Request(this->actor.xyzDistToPlayerSq, 120, 20, 10);
@@ -1249,12 +1249,12 @@ void EnPametfrog_SnapperSpawn(EnPametfrog* this, PlayState* play) {
void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, PlayState* play) {
this->actor.params = GEKKO_GET_SNAPPER;
Quake_Remove(this->quakeIndex);
Quake_RemoveRequest(this->quakeIndex);
this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
this->quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(this->quakeIndex, 20000);
Quake_SetQuakeValues(this->quakeIndex, 17, 0, 0, 0);
Quake_SetCountdown(this->quakeIndex, 12);
Quake_SetPerturbations(this->quakeIndex, 17, 0, 0, 0);
Quake_SetDuration(this->quakeIndex, 12);
Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150);
@@ -7,7 +7,7 @@
#include "z_en_po_sisters.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_4000)
#define THIS ((EnPoSisters*)thisx)
+2 -1
View File
@@ -4,10 +4,11 @@
* Description: Poe
*/
#include "prevent_bss_reordering.h"
#include "z_en_poh.h"
#include "objects/object_po/object_po.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE)
#define THIS ((EnPoh*)thisx)
@@ -195,7 +195,7 @@ void EnStopHeishi_UpdateHeadThirdDay(EnStopheishi* this) {
this->headTurnTimer1 = 50;
}
}
} else if ((this->headTurnTimer1 == 0) && (Quake_NumActiveQuakes() != 0) && (this->headTurnTimer2 >= 6)) {
} else if ((this->headTurnTimer1 == 0) && (Quake_GetNumActiveQuakes() != 0) && (this->headTurnTimer2 >= 6)) {
this->headTurnTimer2 = 0;
}
}
@@ -350,7 +350,7 @@ void EnTanron5_Update(Actor* thisx, PlayState* play2) {
this->actor.shape.rot.y += phi_v0;
Actor_PlaySfx(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION);
func_800BC848(&this->actor, play, 4, 4);
Actor_RequestQuakeAndRumble(&this->actor, play, 4, 4);
this->unk_1A0++;
} else {
Vec3f sp90;
@@ -425,7 +425,7 @@ void func_80A916F0(EnTest6* this, PlayState* play) {
CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]);
func_800B7298(play, NULL, PLAYER_CSMODE_END);
EnTest6_DisableMotionBlur();
Distortion_ClearType(DISTORTION_TYPE_5);
Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME);
Actor_Kill(&this->actor);
}
@@ -491,8 +491,8 @@ void func_80A91760(EnTest6* this, PlayState* play) {
}
}
EnTest6_EnableMotionBlur(120);
Distortion_SetType(DISTORTION_TYPE_5);
Distortion_SetCountdown(80);
Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME);
Distortion_SetDuration(80);
play->unk_18844 = true;
this->cueId = 95;
}
@@ -546,7 +546,7 @@ void func_80A91760(EnTest6* this, PlayState* play) {
if (this->unk_27A == 10) {
this->unk_14C = 0.1f;
EnTest6_DisableMotionBlur();
Distortion_ClearType(DISTORTION_TYPE_5);
Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME);
play->unk_18844 = false;
if (this->unk_254 != NULL) {
ZeldaArena_Free(this->unk_254);
@@ -646,7 +646,7 @@ void func_80A92118(EnTest6* this, PlayState* play) {
CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_SONG_WARP]);
func_800B7298(play, NULL, PLAYER_CSMODE_END);
EnTest6_DisableMotionBlur();
Distortion_ClearType(DISTORTION_TYPE_5);
Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME);
Actor_Kill(&this->actor);
}
@@ -713,8 +713,8 @@ void func_80A92188(EnTest6* this, PlayState* play) {
case 115:
EnTest6_EnableMotionBlur(20);
Distortion_SetType(DISTORTION_TYPE_5);
Distortion_SetCountdown(90);
Distortion_Request(DISTORTION_TYPE_SONG_OF_TIME);
Distortion_SetDuration(90);
this->cueId = 2;
break;
@@ -744,7 +744,7 @@ void func_80A92188(EnTest6* this, PlayState* play) {
case 14:
case 15:
EnTest6_EnableMotionBlur(50);
Distortion_ClearType(DISTORTION_TYPE_5);
Distortion_RemoveRequest(DISTORTION_TYPE_SONG_OF_TIME);
this->cueId = 0;
break;
@@ -7,7 +7,7 @@
#include "prevent_bss_reordering.h"
#include "z_en_thiefbird.h"
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000)
#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_80000000)
#define THIS ((EnThiefbird*)thisx)
@@ -4,6 +4,7 @@
* Description: Beaver Race Ring
*/
#include "prevent_bss_reordering.h"
#include "z_en_twig.h"
#include "objects/object_twig/object_twig.h"
+2 -2
View File
@@ -8,8 +8,8 @@
#include "objects/gameplay_keep/gameplay_keep.h"
#include "overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h"
#define FLAGS \
(ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \
#define FLAGS \
(ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_IGNORE_QUAKE | ACTOR_FLAG_100000 | \
ACTOR_FLAG_CANT_LOCK_ON | ACTOR_FLAG_80000000)
#define THIS ((EnWiz*)thisx)
@@ -117,16 +117,16 @@ u32 func_80BB9A1C(ObjChan* this, f32 arg1) {
f32 sp20;
sp20 = Math_SinS(this->unk1D4) * this->unk1D0;
temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1;
temp_f6 = (Math_CosS(this->unk1D4) * (400 * M_PI / 0x8000) * this->unk1D0) + arg1;
if (temp_f6 != 0.0f) {
this->unk1D4 = RAD_TO_BINANG(func_80086B30(sp20 * 0.03834952f, temp_f6));
this->unk1D4 = RAD_TO_BINANG(func_80086B30(sp20 * (400 * M_PI / 0x8000), temp_f6));
} else if (sp20 >= 0.0f) {
this->unk1D4 = 0x4000;
} else {
this->unk1D4 = -0x4000;
}
if (Math_CosS(this->unk1D4) != 0.0f) {
this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * 0.03834952f));
this->unk1D0 = (temp_f6 / (Math_CosS(this->unk1D4) * (400 * M_PI / 0x8000)));
} else {
this->unk1D0 = sp20;
}
@@ -174,7 +174,7 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) {
func_809B17D0(play, this, &temp->unk_00);
temp_fs0 = Math3D_Vec3fDistSq(&temp->unk_00, &GET_PLAYER(play)->actor.world.pos);
if (temp_fs0 < SQ(240.0f)) {
quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
if (temp_fs0 < SQ(120.0f)) {
quakeVerticalMag = 4;
} else {
@@ -182,8 +182,8 @@ void ObjChikuwa_Update(Actor* thisx, PlayState* play) {
}
Quake_SetSpeed(quakeIndex, 17232);
Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 7);
Quake_SetPerturbations(quakeIndex, quakeVerticalMag, 0, 0, 0);
Quake_SetDuration(quakeIndex, 7);
}
}
}
@@ -458,20 +458,20 @@ void func_80B139F4(ObjDhouse* this, PlayState* play) {
s16 quakeIndex;
if (this->unk_1370 == 117) {
quakeIndex = Quake_Add(camera, QUAKE_TYPE_3);
quakeIndex = Quake_Request(camera, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 8, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 17);
Quake_SetPerturbations(quakeIndex, 8, 0, 0, 0);
Quake_SetDuration(quakeIndex, 17);
} else if (this->unk_1370 == 105) {
quakeIndex = Quake_Add(camera, QUAKE_TYPE_3);
quakeIndex = Quake_Request(camera, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 20);
Quake_SetPerturbations(quakeIndex, 7, 0, 0, 0);
Quake_SetDuration(quakeIndex, 20);
} else if (this->unk_1370 == 90) {
quakeIndex = Quake_Add(camera, QUAKE_TYPE_3);
quakeIndex = Quake_Request(camera, QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 62);
Quake_SetPerturbations(quakeIndex, 5, 0, 0, 0);
Quake_SetDuration(quakeIndex, 62);
}
this->unk_1370--;
@@ -281,7 +281,7 @@ void ObjDora_UpdateCollision(ObjDora* this, PlayState* play) {
this->lastGongHitType = DORA_HIT_STRONG;
}
func_800BC848(&this->actor, play, 5, 10);
Actor_RequestQuakeAndRumble(&this->actor, play, 5, 10);
ObjDora_SetupMoveGong(this);
if ((ObjDora_IsHalfHour(time) == true) && (this->rupeeDropTimer == 0)) {
@@ -74,7 +74,7 @@ void ObjHariko_BobHead(ObjHariko* this, PlayState* play) {
}
void ObjHariko_CheckForQuakes(ObjHariko* this) {
if (Quake_NumActiveQuakes() != 0) {
if (Quake_GetNumActiveQuakes() != 0) {
ObjHariko_SetupBobHead(this);
}
}
@@ -293,13 +293,13 @@ void func_80A54600(PlayState* play, Vec3f* arg1, f32 arg2, f32 arg3) {
}
}
void ObjHugebombiwa_AddQuake(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) {
void ObjHugebombiwa_RequestQuakeAndRumble(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) {
s32 pad[2];
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 7);
Quake_SetPerturbations(quakeIndex, quakeVerticalMag, 0, 0, 0);
Quake_SetDuration(quakeIndex, 7);
Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150);
}
@@ -516,7 +516,7 @@ void func_80A55064(ObjHugebombiwa* this, PlayState* play) {
ptr->unk_24 = 1;
func_80A53E60(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 9.8f);
if ((play->gameplayFrames % 4) == 0) {
ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1);
ObjHugebombiwa_RequestQuakeAndRumble(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1);
}
}
}
@@ -612,7 +612,7 @@ void func_80A55564(ObjHugebombiwa* this, PlayState* play) {
ptr->unk_24 = 1;
func_80A54600(play, &ptr->unk_0C, ptr->unk_18, ptr->unk_00.y * 10.1f);
if ((play->gameplayFrames % 4) == 0) {
ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1);
ObjHugebombiwa_RequestQuakeAndRumble(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1);
}
}
}
@@ -134,10 +134,10 @@ void func_8093D7A0(ObjLift* this, PlayState* play) {
if (OBJLIFT_GET_7(&this->dyna.actor) == 7) {
func_8093D9C0(this);
} else {
quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_1);
quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_1);
Quake_SetSpeed(quakeIndex, 10000);
Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 20);
Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0);
Quake_SetDuration(quakeIndex, 20);
func_8093D88C(this);
}
@@ -61,13 +61,13 @@ void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) {
mtx->zw = panel->pos.z;
}
void ObjTokeiStep_AddQuake(ObjTokeiStep* this, PlayState* play) {
void ObjTokeiStep_RequestQuakeAndRumble(ObjTokeiStep* this, PlayState* play) {
s32 pad[2];
s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
s16 quakeIndex = Quake_Request(GET_ACTIVE_CAM(play), QUAKE_TYPE_3);
Quake_SetSpeed(quakeIndex, 20000);
Quake_SetQuakeValues(quakeIndex, 1, 0, 0, 0);
Quake_SetCountdown(quakeIndex, 7);
Quake_SetPerturbations(quakeIndex, 1, 0, 0, 0);
Quake_SetDuration(quakeIndex, 7);
Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10);
}
@@ -180,7 +180,7 @@ s32 ObjTokeiStep_OpenProcess(ObjTokeiStep* this, PlayState* play) {
}
if (panel->numBounces == 1) {
ObjTokeiStep_SpawnDust(this2, panel, play);
ObjTokeiStep_AddQuake(this2, play);
ObjTokeiStep_RequestQuakeAndRumble(this2, play);
}
}
}
@@ -72,7 +72,7 @@ void OceffWipe5_Draw(Actor* thisx, PlayState* play) {
s32 i;
s32 pad2;
Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye;
Camera* cam = GET_ACTIVE_CAM(play);
Camera* activeCam = GET_ACTIVE_CAM(play);
Vec3f quakeOffset;
u8 alpha;
s32 colorIndex = OCEFF_WIPE5_GET_SONG_TYPE(thisx) * 3;
@@ -88,7 +88,7 @@ void OceffWipe5_Draw(Actor* thisx, PlayState* play) {
colorIndex = 0;
}
Camera_GetQuakeOffset(&quakeOffset, cam);
Camera_GetQuakeOffset(&quakeOffset, activeCam);
if (this->counter < 32) {
z = Math_SinS(this->counter << 9) * phi_fv1;