summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/z_actor.c63
-rw-r--r--src/code/z_debug.c2
-rw-r--r--src/code/z_en_a_keep.c2
-rw-r--r--src/code/z_en_item00.c2
4 files changed, 47 insertions, 22 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 964d434b4..ca7ca7ebf 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -841,7 +841,10 @@ void Actor_Destroy(Actor* actor, PlayState* play) {
}
}
-void func_8002D7EC(Actor* actor) {
+/**
+ * Update actor's position factoring in velocity and collider displacement
+ */
+void Actor_UpdatePos(Actor* actor) {
f32 speedRate = R_UPDATE_RATE * 0.5f;
actor->world.pos.x += (actor->velocity.x * speedRate) + actor->colChkInfo.displacement.x;
@@ -849,22 +852,34 @@ void func_8002D7EC(Actor* actor) {
actor->world.pos.z += (actor->velocity.z * speedRate) + actor->colChkInfo.displacement.z;
}
-void func_8002D868(Actor* actor) {
+/**
+ * Update actor's velocity accounting for gravity (without dropping below minimum y velocity)
+ */
+void Actor_UpdateVelocityXZGravity(Actor* actor) {
actor->velocity.x = Math_SinS(actor->world.rot.y) * actor->speed;
actor->velocity.z = Math_CosS(actor->world.rot.y) * actor->speed;
actor->velocity.y += actor->gravity;
+
if (actor->velocity.y < actor->minVelocityY) {
actor->velocity.y = actor->minVelocityY;
}
}
-void Actor_MoveForward(Actor* actor) {
- func_8002D868(actor);
- func_8002D7EC(actor);
+/**
+ * Move actor while accounting for its current velocity and gravity.
+ * `actor.speed` is used as the XZ velocity.
+ * The actor will move in the direction of its world yaw.
+ */
+void Actor_MoveXZGravity(Actor* actor) {
+ Actor_UpdateVelocityXZGravity(actor);
+ Actor_UpdatePos(actor);
}
-void func_8002D908(Actor* actor) {
+/**
+ * Update actor's velocity without gravity.
+ */
+void Actor_UpdateVelocityXYZ(Actor* actor) {
f32 speedXZ = Math_CosS(actor->world.rot.x) * actor->speed;
actor->velocity.x = Math_SinS(actor->world.rot.y) * speedXZ;
@@ -872,23 +887,33 @@ void func_8002D908(Actor* actor) {
actor->velocity.z = Math_CosS(actor->world.rot.y) * speedXZ;
}
-void func_8002D97C(Actor* actor) {
- func_8002D908(actor);
- func_8002D7EC(actor);
+/**
+ * Move actor while accounting for its current velocity.
+ * `actor.speed` is used as the XYZ velocity.
+ * The actor will move in the direction of its world yaw and pitch, with positive pitch moving upwards.
+ */
+void Actor_MoveXYZ(Actor* actor) {
+ Actor_UpdateVelocityXYZ(actor);
+ Actor_UpdatePos(actor);
}
-void func_8002D9A4(Actor* actor, f32 arg1) {
- actor->speed = Math_CosS(actor->world.rot.x) * arg1;
- actor->velocity.y = -Math_SinS(actor->world.rot.x) * arg1;
+/**
+ * From a given XYZ speed value, set the corresponding XZ speed as `actor.speed`, and Y speed as Y velocity.
+ * Only the actor's world pitch is factored in, with positive pitch moving downwards.
+ */
+void Actor_SetProjectileSpeed(Actor* actor, f32 speedXYZ) {
+ actor->speed = Math_CosS(actor->world.rot.x) * speedXYZ;
+ actor->velocity.y = -Math_SinS(actor->world.rot.x) * speedXYZ;
}
-void func_8002D9F8(Actor* actor, SkelAnime* skelAnime) {
- Vec3f sp1C;
+void Actor_UpdatePosByAnimation(Actor* actor, SkelAnime* skelAnime) {
+ Vec3f posDiff;
+
+ SkelAnime_UpdateTranslation(skelAnime, &posDiff, actor->shape.rot.y);
- SkelAnime_UpdateTranslation(skelAnime, &sp1C, actor->shape.rot.y);
- actor->world.pos.x += sp1C.x * actor->scale.x;
- actor->world.pos.y += sp1C.y * actor->scale.y;
- actor->world.pos.z += sp1C.z * actor->scale.z;
+ actor->world.pos.x += posDiff.x * actor->scale.x;
+ actor->world.pos.y += posDiff.y * actor->scale.y;
+ actor->world.pos.z += posDiff.z * actor->scale.z;
}
s16 Actor_WorldYawTowardActor(Actor* actorA, Actor* actorB) {
@@ -4090,7 +4115,7 @@ s32 func_80035124(Actor* actor, PlayState* play) {
if (Actor_HasParent(actor, play)) {
actor->params = 1;
} else if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
- Actor_MoveForward(actor);
+ Actor_MoveXZGravity(actor);
Math_SmoothStepToF(&actor->speed, 0.0f, 1.0f, 0.1f, 0.0f);
} else if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && (actor->velocity.y < -4.0f)) {
ret = 1;
diff --git a/src/code/z_debug.c b/src/code/z_debug.c
index 630cfc1ba..63f2eb432 100644
--- a/src/code/z_debug.c
+++ b/src/code/z_debug.c
@@ -156,7 +156,7 @@ void DbCamera_DrawScreenText(GfxPrint* printer) {
/**
* Updates the state of the Reg Editor according to user input.
* Also contains a controller rumble test that can be interfaced with via related REGs.
-*/
+ */
void Regs_UpdateEditor(Input* input) {
s32 dPadInputCur;
s32 pageDataStart = ((gRegEditor->regGroup * REG_PAGES) + gRegEditor->regPage - 1) * REGS_PER_PAGE;
diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c
index b58e813cd..572479dc7 100644
--- a/src/code/z_en_a_keep.c
+++ b/src/code/z_en_a_keep.c
@@ -312,7 +312,7 @@ void EnAObj_Update(Actor* thisx, PlayState* play) {
EnAObj* this = (EnAObj*)thisx;
this->actionFunc(this, play);
- Actor_MoveForward(&this->dyna.actor);
+ Actor_MoveXZGravity(&this->dyna.actor);
if (this->dyna.actor.gravity != 0.0f) {
if (this->dyna.actor.params != A_OBJ_BOULDER_FRAGMENT) {
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index 18e8ef111..3d336e5bc 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -576,7 +576,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) {
} else {
sp3A = 1;
- Actor_MoveForward(&this->actor);
+ Actor_MoveXZGravity(&this->actor);
}
if (sp3A || D_80157D94[0]) {