func_80274A18: Decoded c to human readable

This commit is contained in:
Spencer Vaughn 2022-09-15 21:19:09 -05:00
parent e02b37b203
commit e36dc779ab
4 changed files with 198 additions and 196 deletions

View File

@ -190,7 +190,7 @@ typedef struct Npc {
} blur; } blur;
/* 0x024 */ s32 spriteInstanceID; /* 0x024 */ s32 spriteInstanceID;
/* 0x028 */ AnimID currentAnim; /* 0x028 */ AnimID currentAnim;
/* 0x02C */ s32 animNotifyValue; /* 0x02C */ s32 unk_2C;
/* 0x030 */ f32 animationSpeed; /* 0x030 */ f32 animationSpeed;
/* 0x034 */ f32 renderYaw; /* 0x034 */ f32 renderYaw;
/* 0x038 */ Vec3f pos; /* 0x038 */ Vec3f pos;
@ -1534,7 +1534,7 @@ typedef struct ActorPart {
/* 0x80 */ s32 partFlags3; /* 0x80 */ s32 partFlags3;
/* 0x84 */ s32 unk_84; /* 0x84 */ s32 unk_84;
/* 0x88 */ u32 currentAnimation; /* 0x88 */ u32 currentAnimation;
/* 0x8C */ s32 animNotifyValue; /* 0x8C */ s32 unk_8C;
/* 0x90 */ f32 animationRate; /* 0x90 */ f32 animationRate;
/* 0x94 */ u32* idleAnimations; /* 0x94 */ u32* idleAnimations;
/* 0x98 */ s16 opacity; /* 0x98 */ s16 opacity;
@ -1734,10 +1734,10 @@ typedef struct ActorState { // TODO: Make the first field of this an ActorMoveme
/* 0x00 */ Vec3f currentPos; /* 0x00 */ Vec3f currentPos;
/* 0x0C */ Vec3f goalPos; /* 0x0C */ Vec3f goalPos;
/* 0x18 */ Vec3f unk_18; /* 0x18 */ Vec3f unk_18;
/* 0x24 */ f32 unk_24; /* 0x24 */ f32 currentDegAngle;
/* 0x28 */ f32 unk_28; /* 0x28 */ f32 angularVelocity;
/* 0x2C */ f32 unk_2C; /* 0x2C */ f32 unk_2C;
/* 0x30 */ Vec3f unk_30; /* 0x30 */ Vec3f velocityVector;
/* 0x3C */ f32 acceleration; /* 0x3C */ f32 acceleration;
/* 0x40 */ f32 speed; /* 0x40 */ f32 speed;
/* 0x44 */ f32 velocity; /* 0x44 */ f32 velocity;
@ -1897,10 +1897,10 @@ typedef struct PlayerStatus {
/* 0x000 */ s32 flags; // PlayerStatusFlags /* 0x000 */ s32 flags; // PlayerStatusFlags
/* 0x004 */ u32 animFlags; /* 0x004 */ u32 animFlags;
/* 0x008 */ s16 currentStateTime; /* 0x008 */ s16 currentStateTime;
/* 0x00A */ s8 shiverTime; /* 0x00A */ s8 unk_0A;
/* 0x00B */ char unk_0B; /* 0x00B */ char unk_0B;
/* 0x00C */ s8 peachDisguise; /* 0x00C */ s8 peachDisguise;
/* 0x00D */ s8 availableDisguiseType; ///< set in main map scripts /* 0x00D */ s8 unk_0D;
/* 0x00E */ u8 alpha1; /* 0x00E */ u8 alpha1;
/* 0x00F */ u8 alpha2; /* 0x00F */ u8 alpha2;
/* 0x010 */ s16 blinkTimer; /* 0x010 */ s16 blinkTimer;
@ -1939,13 +1939,13 @@ typedef struct PlayerStatus {
/* 0x0B6 */ s8 actionSubstate; /* 0x0B6 */ s8 actionSubstate;
/* 0x0B7 */ char unk_B7; /* 0x0B7 */ char unk_B7;
/* 0x0B8 */ AnimID anim; /* 0x0B8 */ AnimID anim;
/* 0x0BC */ u16 animNotifyValue; /* 0x0BC */ u16 unk_BC;
/* 0x0BE */ s8 renderMode; /* 0x0BE */ s8 renderMode;
/* 0x0BF */ s8 hazardType; /* 0x0BF */ s8 hazardType;
/* 0x0C0 */ s16 timeInAir; /* 0x0C0 */ s16 timeInAir;
/* 0x0C2 */ s16 unk_C2; /* 0x0C2 */ s16 unk_C2;
/* 0x0C4 */ s8 peachItemHeld; /* 0x0C4 */ s8 peachItemHeld;
/* 0x0C5 */ s8 camResetDelay; /* 0x0C5 */ s8 unk_C5;
/* 0x0C6 */ s16 interactingWithID; /* 0x0C6 */ s16 interactingWithID;
/* 0x0C8 */ Npc* encounteredNPC; /* 0x0C8 */ Npc* encounteredNPC;
/* 0x0CC */ s32 shadowID; /* 0x0CC */ s32 shadowID;

View File

@ -1142,7 +1142,7 @@ ApiStatus func_80273444(Evt* script, s32 isInitialCall) {
playerState->currentPos.y += playerVel; playerState->currentPos.y += playerVel;
playerState->velocity -= playerState->acceleration; playerState->velocity -= playerState->acceleration;
temp_f20_2 = playerState->speed; temp_f20_2 = playerState->speed;
add_xz_vec3f(&playerState->currentPos, temp_f20_2 + sin_rad(DEG_TO_RAD(playerState->unk_24), playerState->angle); add_xz_vec3f(&playerState->currentPos, temp_f20_2 + sin_rad((playerState->unk_24 * TAU) / 360.0f), playerState->angle);
playerState->unk_24 += playerState->unk_28; playerState->unk_24 += playerState->unk_28;
playerState->unk_24 = clamp_angle(playerState->unk_24); playerState->unk_24 = clamp_angle(playerState->unk_24);
player->currentPos.x = playerState->currentPos.x; player->currentPos.x = playerState->currentPos.x;
@ -1712,211 +1712,213 @@ ApiStatus func_802749F8(Evt* script, s32 isInitialCall) {
} }
// INCLUDE_ASM(s32, "19FAF0", func_80274A18); // INCLUDE_ASM(s32, "19FAF0", func_80274A18);
// Jump on an enemy
s32 func_80274A18(Evt *script, s32 isInitialCall) { s32 func_80274A18(Evt *script, s32 isInitialCall) {
Actor *temp_s2; Actor* player;
ActorState *temp_s0; ActorState* playerState;
f32 temp_f0; f32 distance;
f32 temp_f0_2; f32 currentPosY;
f32 temp_f12; f32 rotatedAngle_1;
f32 temp_f12_2; f32 rotatedAngle;
f32 temp_f20; f32 currentPosZ;
f32 temp_f22; f32 currentPosX;
f32 temp_f24; f32 goalPosX;
f32 temp_f26; f32 goalPosZ;
f32 temp_f2; f32 speed;
f32 temp_f2_2; f32 goalPosY;
f32 temp_f6; f32 playerMoveTime_2;
f32 temp_f6_2; f32 updatedPosX;
f32 temp_f8; f32 bounceDivisor;
f32 temp_f8_2; f32 bounceDivisor_2;
f32 var_f8; f32 remainingDistance;
f64 temp_f20_2; f64 currentPosX_2;
f64 var_f0; f64 sine;
f64 var_f0_2; f64 sine_2;
f64 var_f20; f64 velocity;
f64 var_f20_2; f64 velocity_2;
f64 var_f22; f64 acceleration;
f64 var_f22_2; f64 acceleration_2;
f64 var_f2; f64 var_f2;
f64 var_f2_2; f64 var_f2_2;
s16 temp_v0; s16 playerMoveTime;
s16 temp_v0_2; s16 playerMoveTime_3;
s16 temp_v1; s16 playerMoveTime_1;
s16 temp_v1_3; s16 playerMoveTime_4;
s32 *temp_s1; Bytecode* args;
s32 temp_f10; s32 time;
s32 temp_v1_2; s32 eventScriptSection;
s32 var_v0; s32 defaultReturnValue;
temp_s2 = gBattleStatus.playerActor; player = gBattleStatus.playerActor;
temp_s1 = script->ptrReadPos; args = script->ptrReadPos;
temp_s0 = &temp_s2->state; playerState = &player->state;
if (isInitialCall != 0) { if (isInitialCall != 0) {
temp_s2->state.moveTime = evt_get_variable(script, *temp_s1); player->state.moveTime = evt_get_variable(script, *args);
temp_s2->state.moveArcAmplitude = evt_get_variable(script, *(temp_s1 + 4)); player->state.moveArcAmplitude = evt_get_variable(script, *(args + 4));
script->functionTemp[1] = 0; script->functionTemp[1] = 0;
script->functionTemp[0] = 0; script->functionTemp[0] = 0;
if (temp_s2->state.moveArcAmplitude == 1) { if (player->state.moveArcAmplitude == 1) {
script->functionTemp[0] = 2; script->functionTemp[0] = 2;
} }
} }
if (script->functionTemp[0] == 0) { if (script->functionTemp[0] == 0) {
temp_f24 = temp_s0->goalPos.x; goalPosX = playerState->goalPos.x;
temp_f26 = temp_s0->goalPos.z; goalPosZ = playerState->goalPos.z;
temp_s0->currentPos.x = temp_s2->currentPos.x; playerState->currentPos.x = player->currentPos.x;
temp_f22 = temp_s0->currentPos.x; currentPosX = playerState->currentPos.x;
temp_s0->currentPos.y = temp_s2->currentPos.y; playerState->currentPos.y = player->currentPos.y;
temp_f20 = temp_s2->currentPos.z; currentPosZ = player->currentPos.z;
temp_s0->currentPos.z = temp_f20; playerState->currentPos.z = currentPosZ;
temp_s0->angle = atan2(temp_f22, temp_f20, temp_f24, temp_f26); playerState->angle = atan2(currentPosX, currentPosZ, goalPosX, goalPosZ);
temp_f0 = dist2D(temp_f22, temp_f20, temp_f24, temp_f26); distance = dist2D(currentPosX, currentPosZ, goalPosX, goalPosZ);
temp_v0 = temp_s0->moveTime; playerMoveTime = playerState->moveTime;
temp_s0->distance = temp_f0; playerState->distance = distance;
if (temp_v0 == 0) { if (playerMoveTime == 0) {
temp_f10 = (s32) (temp_f0 / temp_s0->speed); time = (s32) (distance / playerState->speed);
temp_s0->moveTime = (s16) temp_f10; playerState->moveTime = (s16) time;
var_f8 = temp_f0 - ((f32) (s16) temp_f10 * temp_s0->speed); remainingDistance = distance - ((f32) (s16) time * playerState->speed);
} else { } else {
temp_f2 = temp_f0 / (f32) temp_v0; speed = distance / (f32) playerMoveTime;
temp_s0->speed = temp_f2; playerState->speed = speed;
var_f8 = temp_s0->distance - ((f32) temp_s0->moveTime * temp_f2); remainingDistance = playerState->distance - ((f32) playerState->moveTime * speed);
} }
temp_v1 = temp_s0->moveTime; playerMoveTime_1 = playerState->moveTime;
var_v0 = 2;
if (temp_v1 != 0) { defaultReturnValue = 2;
temp_f6 = (f32) temp_s0->moveTime; if (playerMoveTime_1 != 0) {
temp_s0->acceleration = 3.14159f / temp_f6; playerMoveTime_2 = (f32) playerState->moveTime;
temp_s0->unk_30.x = (temp_s0->goalPos.x - temp_s0->currentPos.x) / (f32) temp_v1; playerState->acceleration = 3.14159f / playerMoveTime_2;
temp_s0->velocity = 0.0f; playerState->velocityVector.x = (playerState->goalPos.x - playerState->currentPos.x) / (f32) playerMoveTime_1;
temp_s0->unk_30.y = (temp_s0->goalPos.y - temp_s0->currentPos.y) / temp_f6; playerState->velocity = 0.0f;
temp_s0->unk_30.z = (temp_s0->goalPos.z - temp_s0->currentPos.z) / temp_f6; playerState->velocityVector.y = (playerState->goalPos.y - playerState->currentPos.y) / playerMoveTime_2;
temp_s0->speed += var_f8 / temp_f6; playerState->velocityVector.z = (playerState->goalPos.z - playerState->currentPos.z) / playerMoveTime_2;
if (temp_s0->moveArcAmplitude < 3) { playerState->speed += remainingDistance / playerMoveTime_2;
temp_f8 = (f32) ((f64) (f32) ((f64) (f32) ((f64) temp_s0->distance - 20.0) / 6.0) + 47.0); if (playerState->moveArcAmplitude < 3) {
temp_s0->unk_24 = 90.0f; bounceDivisor = (f32) ((f64) (f32) ((f64) (f32) ((f64) playerState->distance - 20.0) / 6.0) + 47.0);
temp_s0->bounceDivisor = temp_f8; playerState->currentDegAngle = 90.0f;
temp_s0->unk_28 = (f32) (0x168 / (s16) temp_s0->moveTime); playerState->bounceDivisor = bounceDivisor;
if (temp_s0->moveArcAmplitude == 2) { playerState->angularVelocity = (f32) (0x168 / (s16) playerState->moveTime);
temp_s0->bounceDivisor = (f32) ((f64) temp_f8 * 1.12); if (playerState->moveArcAmplitude == 2) {
playerState->bounceDivisor = (f32) ((f64) bounceDivisor * 1.12);
} }
temp_s0->unk_18.x = 0.0f; playerState->unk_18.x = 0.0f;
temp_s0->unk_18.y = 0.0f; playerState->unk_18.y = 0.0f;
var_f20 = (f64) temp_s0->velocity; velocity = (f64) playerState->velocity;
var_f22 = (f64) temp_s0->acceleration; acceleration = (f64) playerState->acceleration;
var_f2 = 0.53; var_f2 = 0.53;
var_f0 = (f64) sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f); sine = (f64) sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f);
} else { } else {
temp_f8_2 = (f32) ((f64) (f32) ((f64) (f32) ((f64) temp_s0->distance - 20.0) / 6.0) + 47.0); bounceDivisor_2 = (f32) ((f64) (f32) ((f64) (f32) ((f64) playerState->distance - 20.0) / 6.0) + 47.0);
temp_s0->unk_24 = 90.0f; playerState->currentDegAngle = 90.0f;
temp_s0->bounceDivisor = temp_f8_2; playerState->bounceDivisor = bounceDivisor_2;
temp_s0->unk_28 = (f32) (0x168 / (s16) temp_s0->moveTime); playerState->angularVelocity = (f32) (0x168 / (s16) playerState->moveTime);
if (temp_s0->moveArcAmplitude == 4) { if (playerState->moveArcAmplitude == 4) {
temp_s0->bounceDivisor = (f32) ((f64) temp_f8_2 * 1.25); playerState->bounceDivisor = (f32) ((f64) bounceDivisor_2 * 1.25);
} }
temp_s0->unk_18.x = 0.0f; playerState->unk_18.x = 0.0f;
temp_s0->unk_18.y = 0.0f; playerState->unk_18.y = 0.0f;
var_f20 = (f64) temp_s0->velocity; velocity = (f64) playerState->velocity;
var_f22 = (f64) temp_s0->acceleration; acceleration = (f64) playerState->acceleration;
var_f2 = 0.8; var_f2 = 0.8;
var_f0 = (f64) sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f); sine = (f64) sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f);
} }
temp_s0->velocity = (f32) (var_f20 + ((var_f0 * var_f2 * var_f22) + var_f22)); playerState->velocity = (f32) (velocity + ((sine * var_f2 * acceleration) + acceleration));
set_animation(0, 0, temp_s0->animJumpRise); set_animation(0, 0, playerState->animJumpRise);
sfx_play_sound_at_position(0x160, 0, temp_s2->currentPos.x, temp_s2->currentPos.y, temp_s2->currentPos.z); sfx_play_sound_at_position(0x160, 0, player->currentPos.x, player->currentPos.y, player->currentPos.z);
script->functionTemp[0] = 1; script->functionTemp[0] = 1;
goto block_16; goto block_16;
} }
/* Duplicate return node #38. Try simplifying control flow for better match */ /* Duplicate return node #38. Try simplifying control flow for better match */
return var_v0; return defaultReturnValue;
} }
block_16: block_16:
temp_v1_2 = script->functionTemp[0]; eventScriptSection = script->functionTemp[0];
if (temp_v1_2 != 2) { if (eventScriptSection != 2) {
if (temp_v1_2 < 3) { if (eventScriptSection < 3) {
if (temp_v1_2 != 1) { if (eventScriptSection != 1) {
return 0; return 0;
} }
if (temp_s0->velocity > 1.570795f) { if (playerState->velocity > 1.570795f) {
set_animation(0, 0, temp_s0->animJumpFall); set_animation(0, 0, playerState->animJumpFall);
} }
temp_f6_2 = temp_s0->currentPos.x + temp_s0->unk_30.x; updatedPosX = playerState->currentPos.x + playerState->velocityVector.x;
temp_s0->currentPos.x = temp_f6_2; playerState->currentPos.x = updatedPosX;
temp_s0->currentPos.y += temp_s0->unk_30.y; playerState->currentPos.y += playerState->velocityVector.y;
temp_s0->currentPos.z += temp_s0->unk_30.z; playerState->currentPos.z += playerState->velocityVector.z;
temp_s0->unk_18.x = temp_s2->currentPos.y; playerState->unk_18.x = player->currentPos.y;
temp_s2->currentPos.x = temp_f6_2; player->currentPos.x = updatedPosX;
temp_s2->currentPos.y = temp_s0->currentPos.y + (temp_s0->bounceDivisor * sin_rad(temp_s0->velocity)); player->currentPos.y = playerState->currentPos.y + (playerState->bounceDivisor * sin_rad(playerState->velocity));
temp_s2->currentPos.z = temp_s0->currentPos.z; player->currentPos.z = playerState->currentPos.z;
temp_f2_2 = temp_s0->goalPos.y; goalPosY = playerState->goalPos.y;
if ((temp_s2->currentPos.y < temp_f2_2) && (temp_s0->moveTime < 3)) { if ((player->currentPos.y < goalPosY) && (playerState->moveTime < 3)) {
temp_s2->currentPos.y = temp_f2_2; player->currentPos.y = goalPosY;
} }
temp_s0->unk_18.y = temp_s2->currentPos.y; playerState->unk_18.y = player->currentPos.y;
if (temp_s0->moveArcAmplitude < 3) { if (playerState->moveArcAmplitude < 3) {
var_f20_2 = (f64) temp_s0->velocity; velocity_2 = (f64) playerState->velocity;
var_f22_2 = (f64) temp_s0->acceleration; acceleration_2 = (f64) playerState->acceleration;
var_f2_2 = 0.53; var_f2_2 = 0.53;
var_f0_2 = (f64) sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f); sine_2 = (f64) sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f);
} else { } else {
var_f20_2 = (f64) temp_s0->velocity; velocity_2 = (f64) playerState->velocity;
var_f22_2 = (f64) temp_s0->acceleration; acceleration_2 = (f64) playerState->acceleration;
var_f2_2 = 0.8; var_f2_2 = 0.8;
var_f0_2 = (f64) sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f); sine_2 = (f64) sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f);
} }
temp_s0->velocity = (f32) (var_f20_2 + ((var_f0_2 * var_f2_2 * var_f22_2) + var_f22_2)); playerState->velocity = (f32) (velocity_2 + ((sine_2 * var_f2_2 * acceleration_2) + acceleration_2));
temp_f12 = temp_s0->unk_24 + temp_s0->unk_28; rotatedAngle_1 = playerState->currentDegAngle + playerState->angularVelocity;
temp_s0->unk_24 = temp_f12; playerState->currentDegAngle = rotatedAngle_1;
temp_s0->unk_24 = clamp_angle(temp_f12); playerState->currentDegAngle = clamp_angle(rotatedAngle_1);
temp_v0_2 = (u16) temp_s0->moveTime - 1; playerMoveTime_3 = (u16) playerState->moveTime - 1;
temp_s0->moveTime = temp_v0_2; playerState->moveTime = playerMoveTime_3;
var_v0 = 0; defaultReturnValue = 0;
if ((temp_v0_2 << 0x10) == 0) { if ((playerMoveTime_3 << 0x10) == 0) {
temp_s2->currentPos.y = temp_s0->goalPos.y; player->currentPos.y = playerState->goalPos.y;
temp_s0->acceleration = 1.8f; playerState->acceleration = 1.8f;
temp_s0->velocity = -(temp_s0->unk_18.x - temp_s0->unk_18.y); playerState->velocity = -(playerState->unk_18.x - playerState->unk_18.y);
set_animation(0, 0, temp_s0->animJumpLand); set_animation(0, 0, playerState->animJumpLand);
return 1; return 1;
} }
/* Duplicate return node #38. Try simplifying control flow for better match */ /* Duplicate return node #38. Try simplifying control flow for better match */
return var_v0; return defaultReturnValue;
} }
if (temp_v1_2 != 3) { if (eventScriptSection != 3) {
return 0; return 0;
} }
goto block_34; goto block_34;
} }
if (gBattleStatus.unk_83 != 0) { if (gBattleStatus.unk_83 != 0) {
temp_s0->moveTime = 1; playerState->moveTime = 1;
temp_s0->acceleration = 1.8f; playerState->acceleration = 1.8f;
temp_s0->unk_24 = 90.0f; playerState->currentDegAngle = 90.0f;
temp_s0->velocity = -(temp_s0->unk_18.x - temp_s0->unk_18.y); playerState->velocity = -(playerState->unk_18.x - playerState->unk_18.y);
temp_s0->bounceDivisor = (f32) ((f64) fabsf(temp_s0->unk_18.x - temp_s0->unk_18.y) / 16.5); playerState->bounceDivisor = (f32) ((f64) fabsf(playerState->unk_18.x - playerState->unk_18.y) / 16.5);
temp_s0->unk_28 = (f32) (0x168 / (s16) temp_s0->moveTime); playerState->angularVelocity = (f32) (0x168 / (s16) playerState->moveTime);
temp_s0->currentPos.x = temp_s2->currentPos.x; playerState->currentPos.x = player->currentPos.x;
temp_s0->currentPos.y = temp_s2->currentPos.y; playerState->currentPos.y = player->currentPos.y;
temp_s0->currentPos.z = temp_s2->currentPos.z; playerState->currentPos.z = player->currentPos.z;
script->functionTemp[0] = 3; script->functionTemp[0] = 3;
block_34: block_34:
temp_f20_2 = (f64) temp_s0->currentPos.x; currentPosX_2 = (f64) playerState->currentPos.x;
temp_s0->currentPos.x = (f32) (temp_f20_2 + ((f64) (temp_s0->bounceDivisor * sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f)) / 33.0)); playerState->currentPos.x = (f32) (currentPosX_2 + ((f64) (playerState->bounceDivisor * sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f)) / 33.0));
temp_f12_2 = temp_s0->unk_24 + temp_s0->unk_28; rotatedAngle = playerState->currentDegAngle + playerState->angularVelocity;
temp_f0_2 = temp_s0->currentPos.y - (temp_s0->bounceDivisor * sin_rad((temp_s0->unk_24 * 6.28318f) / 360.0f)); currentPosY = playerState->currentPos.y - (playerState->bounceDivisor * sin_rad((playerState->currentDegAngle * 6.28318f) / 360.0f));
temp_s0->unk_24 = temp_f12_2; playerState->currentDegAngle = rotatedAngle;
temp_s0->currentPos.y = temp_f0_2; playerState->currentPos.y = currentPosY;
temp_s0->unk_24 = clamp_angle(temp_f12_2); playerState->currentDegAngle = clamp_angle(rotatedAngle);
temp_s2->currentPos.x = temp_s0->currentPos.x; player->currentPos.x = playerState->currentPos.x;
temp_s2->currentPos.y = temp_s0->currentPos.y; player->currentPos.y = playerState->currentPos.y;
temp_s2->currentPos.z = temp_s0->currentPos.z; player->currentPos.z = playerState->currentPos.z;
if (gBattleStatus.flags1 & 0x2000) { if (gBattleStatus.flags1 & 0x2000) {
goto block_35; return 2;
} }
temp_v1_3 = (u16) temp_s0->moveTime - 1; playerMoveTime_4 = (u16) playerState->moveTime - 1;
temp_s0->moveTime = temp_v1_3; playerState->moveTime = playerMoveTime_4;
var_v0 = 1; defaultReturnValue = 1;
if ((temp_v1_3 << 0x10) != 0) { if ((playerMoveTime_4 << 0x10) != 0) {
var_v0 = 0; defaultReturnValue = 0;
} }
return var_v0; return defaultReturnValue;
} }
block_35: block_35:
return 2; return 2;

View File

@ -119,8 +119,8 @@ ApiStatus func_80238000_6FFD80(Evt* evt, s32 isInitialCall) {
state->goalPos.x += targetActorPart->unk_75 * targetActor->scalingFactor; state->goalPos.x += targetActorPart->unk_75 * targetActor->scalingFactor;
state->goalPos.y += targetActorPart->unk_76 * targetActor->scalingFactor; state->goalPos.y += targetActorPart->unk_76 * targetActor->scalingFactor;
state->goalPos.z = state->goalPos.z; state->goalPos.z = state->goalPos.z;
state->unk_24 = (targetActorPart->size.y + targetActorPart->size.x) / 2 / 24.0; state->currentDegAngle = (targetActorPart->size.y + targetActorPart->size.x) / 2 / 24.0;
hud_element_set_scale(D_8023BDB4, state->unk_24 * targetActor->scalingFactor); hud_element_set_scale(D_8023BDB4, state->currentDegAngle * targetActor->scalingFactor);
state->currentPos.x = parakarry->currentPos.x + 8.0f; state->currentPos.x = parakarry->currentPos.x + 8.0f;
state->currentPos.y = parakarry->currentPos.y + 16.0f; state->currentPos.y = parakarry->currentPos.y + 16.0f;
state->currentPos.z = parakarry->currentPos.z; state->currentPos.z = parakarry->currentPos.z;
@ -201,7 +201,7 @@ ApiStatus func_80238000_6FFD80(Evt* evt, s32 isInitialCall) {
} else { } else {
if (D_8023BDBC == 0) { if (D_8023BDBC == 0) {
targetActor = get_actor(parakarry->targetActorID); targetActor = get_actor(parakarry->targetActorID);
tempAngle = fabsf(get_clamped_angle_diff(state->angle, state->bounceDivisor)) / state->unk_24 * targetActor->scalingFactor; tempAngle = fabsf(get_clamped_angle_diff(state->angle, state->bounceDivisor)) / state->currentDegAngle * targetActor->scalingFactor;
if (tempAngle < 3.0f) { if (tempAngle < 3.0f) {
evt->functionTemp[0] = 3; evt->functionTemp[0] = 3;
@ -227,7 +227,7 @@ ApiStatus func_80238000_6FFD80(Evt* evt, s32 isInitialCall) {
case 3: case 3:
targetActor = get_actor(parakarry->targetActorID); targetActor = get_actor(parakarry->targetActorID);
clampedAngleDiff = get_clamped_angle_diff(state->angle, state->bounceDivisor); clampedAngleDiff = get_clamped_angle_diff(state->angle, state->bounceDivisor);
tempAngle = fabsf(clampedAngleDiff) / state->unk_24 * targetActor->scalingFactor; tempAngle = fabsf(clampedAngleDiff) / state->currentDegAngle * targetActor->scalingFactor;
if (state->velocity >= 0.0f) { if (state->velocity >= 0.0f) {
if (clampedAngleDiff < 0.0f) { if (clampedAngleDiff < 0.0f) {
@ -269,7 +269,7 @@ ApiStatus func_80238000_6FFD80(Evt* evt, s32 isInitialCall) {
hudID = D_8023BDC0; hudID = D_8023BDC0;
targetActor = get_actor(parakarry->targetActorID); targetActor = get_actor(parakarry->targetActorID);
clampedAngleDiff = get_clamped_angle_diff(state->angle, state->bounceDivisor); clampedAngleDiff = get_clamped_angle_diff(state->angle, state->bounceDivisor);
tempAngle = fabsf(clampedAngleDiff) / state->unk_24 * targetActor->scalingFactor; tempAngle = fabsf(clampedAngleDiff) / state->currentDegAngle * targetActor->scalingFactor;
if (tempAngle < 7.0f) { if (tempAngle < 7.0f) {
hud_element_set_script(hudID, &HES_StickNeutral); hud_element_set_script(hudID, &HES_StickNeutral);
@ -408,7 +408,7 @@ ApiStatus func_80238E24_700BA4(Evt* evt, s32 isInitialCall) {
parakarry->state.currentPos.x += parakarry->state.speed; parakarry->state.currentPos.x += parakarry->state.speed;
*animationRatePtr = 1.0f; *animationRatePtr = 1.0f;
y = parakarry->state.currentPos.y; y = parakarry->state.currentPos.y;
parakarry->state.currentPos.y = y + (sin_rad(2.0f * sin_rad(DEG_TO_RAD(parakarry->state.moveTime)) * PI_S) * D_8023BD60_703AE0 + 0.5); parakarry->state.currentPos.y = y + (sin_rad(2.0f * sin_rad(parakarry->state.moveTime * TAU / 360.0f) * PI_S) * D_8023BD60_703AE0 + 0.5);
parakarry->state.moveTime += 6; parakarry->state.moveTime += 6;
parakarry->state.moveTime = clamp_angle(parakarry->state.moveTime); parakarry->state.moveTime = clamp_angle(parakarry->state.moveTime);

View File

@ -59,16 +59,16 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
state->unk_30.x = (state->goalPos.x - state->currentPos.x) / state->moveTime; state->velocityVector.x = (state->goalPos.x - state->currentPos.x) / state->moveTime;
state->unk_30.y = (state->goalPos.y - state->currentPos.y) / state->moveTime; state->velocityVector.y = (state->goalPos.y - state->currentPos.y) / state->moveTime;
state->unk_30.z = (state->goalPos.z - state->currentPos.z) / state->moveTime; state->velocityVector.z = (state->goalPos.z - state->currentPos.z) / state->moveTime;
state->acceleration = PI_S / state->moveTime; state->acceleration = PI_S / state->moveTime;
state->velocity = 0.0f; state->velocity = 0.0f;
state->speed += phi_f8 / state->moveTime; state->speed += phi_f8 / state->moveTime;
if (state->moveArcAmplitude < 3) { if (state->moveArcAmplitude < 3) {
state->unk_24 = 90.0f; state->currentDegAngle = 90.0f;
state->unk_28 = 360 / state->moveTime; state->angularVelocity = 360 / state->moveTime;
phi_f8 = state->distance; phi_f8 = state->distance;
phi_f8 -= 20.0; phi_f8 -= 20.0;
phi_f8 /= 6.0; phi_f8 /= 6.0;
@ -81,12 +81,12 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
state->unk_18.y = 0.0f; state->unk_18.y = 0.0f;
phi_f20 = state->velocity; phi_f20 = state->velocity;
temp_f22_2 = state->acceleration; temp_f22_2 = state->acceleration;
phi_f0 = sin_rad(DEG_TO_RAD(state->unk_24)); phi_f0 = sin_rad(state->currentDegAngle * TAU / 360.0f);
phi_f2 = 0.53; phi_f2 = 0.53;
state->velocity = phi_f20 + ((phi_f0 * phi_f2 * temp_f22_2) + temp_f22_2); state->velocity = phi_f20 + ((phi_f0 * phi_f2 * temp_f22_2) + temp_f22_2);
} else { } else {
state->unk_24 = 90.0f; state->currentDegAngle = 90.0f;
state->unk_28 = 360 / state->moveTime; state->angularVelocity = 360 / state->moveTime;
phi_f8 = state->distance; phi_f8 = state->distance;
phi_f8 -= 20.0; phi_f8 -= 20.0;
phi_f8 /= 6.0; phi_f8 /= 6.0;
@ -99,7 +99,7 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
state->unk_18.y = 0.0f; state->unk_18.y = 0.0f;
velocity = state->velocity; velocity = state->velocity;
temp_f22_3 = state->acceleration; temp_f22_3 = state->acceleration;
phi_f0 = sin_rad(DEG_TO_RAD(state->unk_24)); phi_f0 = sin_rad(state->currentDegAngle * TAU / 360.0f);
phi_f2 = 0.8; phi_f2 = 0.8;
state->velocity = velocity + ((phi_f0 * phi_f2 * temp_f22_3) + temp_f22_3); state->velocity = velocity + ((phi_f0 * phi_f2 * temp_f22_3) + temp_f22_3);
} }
@ -115,9 +115,9 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
} }
oldActorX = actor->currentPos.x; oldActorX = actor->currentPos.x;
oldActorY = actor->currentPos.y; oldActorY = actor->currentPos.y;
state->currentPos.x += state->unk_30.x; state->currentPos.x += state->velocityVector.x;
state->currentPos.y = state->currentPos.y + state->unk_30.y; state->currentPos.y = state->currentPos.y + state->velocityVector.y;
state->currentPos.z = state->currentPos.z + state->unk_30.z; state->currentPos.z = state->currentPos.z + state->velocityVector.z;
state->unk_18.x = actor->currentPos.y; state->unk_18.x = actor->currentPos.y;
actor->currentPos.x = state->currentPos.x; actor->currentPos.x = state->currentPos.x;
actor->currentPos.y = state->currentPos.y + (state->bounceDivisor * sin_rad(state->velocity)); actor->currentPos.y = state->currentPos.y + (state->bounceDivisor * sin_rad(state->velocity));
@ -131,19 +131,19 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
if (state->moveArcAmplitude < 3) { if (state->moveArcAmplitude < 3) {
phi_f20_2 = state->velocity; phi_f20_2 = state->velocity;
temp_f22_5 = state->acceleration; temp_f22_5 = state->acceleration;
phi_f0_2 = sin_rad(DEG_TO_RAD(state->unk_24)); phi_f0_2 = sin_rad((state->currentDegAngle * TAU) / 360.0f);
phi_f2_2 = 0.53; phi_f2_2 = 0.53;
state->velocity = phi_f20_2 + ((phi_f0_2 * phi_f2_2 * temp_f22_5) + temp_f22_5); state->velocity = phi_f20_2 + ((phi_f0_2 * phi_f2_2 * temp_f22_5) + temp_f22_5);
} else { } else {
temp_f20_6 = state->velocity; temp_f20_6 = state->velocity;
temp_f22_6 = state->acceleration; temp_f22_6 = state->acceleration;
phi_f0_2 = sin_rad(DEG_TO_RAD(state->unk_24)); phi_f0_2 = sin_rad((state->currentDegAngle * TAU) / 360.0f);
phi_f2_2 = 0.8; phi_f2_2 = 0.8;
state->velocity = temp_f20_6 + ((phi_f0_2 * phi_f2_2 * temp_f22_6) + temp_f22_6); state->velocity = temp_f20_6 + ((phi_f0_2 * phi_f2_2 * temp_f22_6) + temp_f22_6);
} }
state->unk_24 += state->unk_28; state->currentDegAngle += state->angularVelocity;
state->unk_24 = clamp_angle(state->unk_24); state->currentDegAngle = clamp_angle(state->currentDegAngle);
state->moveTime--; state->moveTime--;
if (state->moveTime == 0) { if (state->moveTime == 0) {
actor->currentPos.y = state->goalPos.y; actor->currentPos.y = state->goalPos.y;
@ -156,10 +156,10 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
case 2: case 2:
state->moveTime = 1; state->moveTime = 1;
state->acceleration = 1.8f; state->acceleration = 1.8f;
state->unk_24 = 90.0f; state->currentDegAngle = 90.0f;
state->velocity = -(state->unk_18.x - state->unk_18.y); state->velocity = -(state->unk_18.x - state->unk_18.y);
state->bounceDivisor = fabsf(state->unk_18.x - state->unk_18.y) / 16.5; state->bounceDivisor = fabsf(state->unk_18.x - state->unk_18.y) / 16.5;
state->unk_28 = 360 / state->moveTime; state->angularVelocity = 360 / state->moveTime;
state->currentPos.x = actor->currentPos.x; state->currentPos.x = actor->currentPos.x;
state->currentPos.y = actor->currentPos.y; state->currentPos.y = actor->currentPos.y;
state->currentPos.z = actor->currentPos.z; state->currentPos.z = actor->currentPos.z;
@ -167,10 +167,10 @@ ApiStatus N(UnkFunc62)(Evt* script, s32 isInitialCall) {
// fallthrough // fallthrough
case 3: case 3:
currentPosX64 = state->currentPos.x; // required to match currentPosX64 = state->currentPos.x; // required to match
state->currentPos.x = currentPosX64 + state->bounceDivisor * sin_rad(DEG_TO_RAD(state->unk_24)) / 33.0; state->currentPos.x = currentPosX64 + state->bounceDivisor * sin_rad((state->currentDegAngle * TAU) / 360.0f) / 33.0;
state->currentPos.y -= state->bounceDivisor * sin_rad(DEG_TO_RAD(state->unk_24)); state->currentPos.y -= state->bounceDivisor * sin_rad((state->currentDegAngle * TAU) / 360.0f);
state->unk_24 += state->unk_28; state->currentDegAngle += state->angularVelocity;
state->unk_24 = clamp_angle(state->unk_24); state->currentDegAngle = clamp_angle(state->currentDegAngle);
actor->currentPos.x = state->currentPos.x; actor->currentPos.x = state->currentPos.x;
actor->currentPos.y = state->currentPos.y; actor->currentPos.y = state->currentPos.y;
actor->currentPos.z = state->currentPos.z; actor->currentPos.z = state->currentPos.z;