summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r--src/koopatlas/pathmanager.cpp217
1 files changed, 93 insertions, 124 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index d329c6d..a80c2b4 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -7,6 +7,7 @@
void dWMPathManager_c::setup() {
isMoving = false;
isJumping = false;
+ scaleAnimProgress = -1;
timer = 0.0;
currentPath = 0;
reverseThroughPath = false;
@@ -373,131 +374,88 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
// hang_walk_l = 65,
// hang_walk_r = 66,
- SpammyReport("h\n");
- player->rot.y = direction;
- player->hasSound = false;
- player->hasEffect = false;
- moveSpeed = 3.0f;
-
- switch (path->animation) {
-
- // Running
- case 0:
- player->startAnimation(run, 2.0, 10.0, 0.0);
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_DIRT;
- break;
- case 1:
- player->startAnimation(run, 2.0, 10.0, 0.0);
- player->hasSound = true;
- player->hasEffect = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_SAND;
- player->effectName = "Wm_mr_foot_sand";
- break;
- case 2:
- player->startAnimation(run, 2.0, 10.0, 0.0);
- player->hasSound = true;
- player->hasEffect = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_SNOW;
- player->effectName = "Wm_mr_foot_snow";
- break;
- case 3:
- player->startAnimation(run, 2.0, 10.0, 0.0);
- player->hasSound = true;
- player->hasEffect = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_WATER;
- player->effectName = "Wm_mr_foot_water";
- break;
+ static const struct {
+ PlayerAnim anim;
+ float animParam1, animParam2;
+ s16 forceRotation;
+ float forceSpeed;
+ SFX repeatSound, initialSound;
+ const char *repeatEffect, *initialEffect;
+ } Animations[] = {
+ // Walking
+ {run,2.0f,10.0f, -1,-1.0f, SE_PLY_FOOTNOTE_DIRT,SE_NULL, 0,0},
+ {run,2.0f,10.0f, -1,-1.0f, SE_PLY_FOOTNOTE_CS_SAND,SE_NULL, "Wm_mr_foot_sand",0},
+ {run,2.0f,10.0f, -1,-1.0f, SE_PLY_FOOTNOTE_CS_SNOW,SE_NULL, "Wm_mr_foot_snow",0},
+ {run,2.0f,10.0f, -1,-1.0f, SE_PLY_FOOTNOTE_CS_WATER,SE_NULL, "Wm_mr_foot_water",0},
// Jumping
- case 4:
- player->startAnimation(jump, 1.0, 1.0, 0.0);
- MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
- isJumping = true;
- moveSpeed = 2.5f;
- break;
- case 5:
- player->startAnimation(jump, 1.0, 10.0, 0.0);
- MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
- isJumping = true;
- moveSpeed = 2.5f;
- break;
- case 6:
- player->startAnimation(jump, 1.0, 10.0, 0.0);
- MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
- isJumping = true;
- moveSpeed = 2.5f;
- break;
- case 7:
- player->startAnimation(jump, 1.0, 10.0, 0.0);
- MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1);
- isJumping = true;
- SpawnEffect("Wm_mr_waterwave_out", 0, &player->pos, 0, &player->scale);
- moveSpeed = 2.0f;
- break;
-
- // Climbing
- case 8:
- player->startAnimation(pea_plant, 1.2, 10.0, 0.0);
- player->rot.y = 0x8000;
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
- moveSpeed = 1.5f;
- break;
- case 9:
- player->startAnimation(tree_climb, 1.2, 10.0, 0.0);
- player->rot.y = 0xC000;
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
- moveSpeed = 1.5f;
- break;
- case 10:
- player->startAnimation(tree_climb, 1.2, 10.0, 0.0);
- player->rot.y = 0x4000;
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_CS_ROCK_CLIMB;
- moveSpeed = 1.5f;
- break;
-
- // Others
- case 12:
- player->startAnimation(swim_wait, 1.2, 10.0, 0.0);
- player->hasSound = true;
- player->hasEffect = true;
- player->soundName = SE_PLY_SWIM;
- player->effectName = "Wm_mr_waterswim";
- moveSpeed = 2.0f;
- break;
- case 13:
- player->startAnimation(b_dash2, 3.0, 10.0, 0.0);
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_DIRT;
- moveSpeed = 5.0f;
- break;
- case 14:
- player->startAnimation(wait, 2.0, 10.0, 0.0);
- player->rot.y = 0x0000;
- MapSoundPlayer(SoundRelatedClass, SE_PLY_DOKAN_IN_OUT, 1);
- moveSpeed = 1.0f;
- break;
- case 15:
- player->startAnimation(wait, 2.0, 10.0, 0.0);
- player->rot.y = 0x8000;
- MapSoundPlayer(SoundRelatedClass, SE_OBJ_DOOR_OPEN, 1);
- moveSpeed = 0.2f;
- break;
- case 16:
- player->startAnimation(Tjumped, 2.0, 0.0, 0.0);
- break;
- default:
- SpammyReport("No animtaion?!");
- player->startAnimation(run, 2.0, 10.0, 0.0);
- player->hasSound = true;
- player->soundName = SE_PLY_FOOTNOTE_DIRT;
- break;
+ {jump,1.0f,1.0f, -1,2.5f, SE_NULL,SE_PLY_JUMP, 0,0},
+ {jump,1.0f,10.0f, -1,2.5f, SE_NULL,SE_PLY_JUMP, 0,0},
+ {jump,1.0f,10.0f, -1,2.5f, SE_NULL,SE_PLY_JUMP, 0,0},
+ {jump,1.0f,10.0f, -1,2.5f, SE_NULL,SE_PLY_JUMP, 0,"Wm_mr_waterwave_out"},
+
+ // Ladder up, left, right
+ {pea_plant,1.2f,10.0f, 0x8000,1.5f, SE_PLY_FOOTNOTE_CS_ROCK_CLIMB,SE_NULL, 0,0},
+ {tree_climb,1.2f,10.0f, 0xC000,1.5f, SE_PLY_FOOTNOTE_CS_ROCK_CLIMB,SE_NULL, 0,0},
+ {tree_climb,1.2f,10.0f, 0x4000,1.5f, SE_PLY_FOOTNOTE_CS_ROCK_CLIMB,SE_NULL, 0,0},
+ // Fall (default?)
+ {run,2.0f,10.0f, -1,-1.0f, SE_PLY_FOOTNOTE_DIRT,SE_NULL, 0,0},
+
+ // Swim
+ {swim_wait,1.2f,10.0f, -1,2.0f, SE_PLY_SWIM,SE_NULL, "Wm_mr_waterswim",0},
+ // Run
+ {b_dash2,3.0f,10.0f, -1,5.0f, SE_PLY_FOOTNOTE_DIRT,SE_NULL, 0,0},
+ // Pipe
+ {wait,2.0f,10.0f, 0x8000,1.0f, SE_NULL,SE_PLY_DOKAN_IN_OUT, 0,0},
+ // Door
+ {wait,2.0f,10.0f, 0x8000,0.2f, SE_NULL,SE_OBJ_DOOR_OPEN, 0,0},
+
+ // TJumped
+ {Tjumped,2.0f,0.0f, -1,-1.0f, SE_NULL,SE_NULL, 0,0},
+
+ // Enter/leave cave, these are handled specially
+ {run,1.0f,10.0f, -1,1.0f, SE_NULL,SE_NULL, 0,0},
+ {run,1.0f,10.0f, -1,1.0f, SE_NULL,SE_NULL, 0,0},
+
+ // Invisible, this is handled specially
+ {wait,2.0f,10.0f, -1,1.0f, SE_NULL,SE_NULL, 0,0},
+ };
+
+ isJumping = (path->animation >= dKPPath_s::JUMP && path->animation <= dKPPath_s::JUMP_WATER);
+
+ if (path->animation == dKPPath_s::ENTER_CAVE || path->animation == dKPPath_s::LEAVE_CAVE) {
+ scaleAnimProgress = 60;
+ if (path->animation == dKPPath_s::LEAVE_CAVE)
+ player->scale = (Vec){0.0f,0.0f,0.0f};
}
-
- SpammyReport("i\n");
+
+ player->visible = (path->animation != dKPPath_s::INVISIBLE);
+
+ int id = (path->animation < dKPPath_s::MAX_ANIM) ? 0 : (int)path->animation;
+
+ player->startAnimation(Animations[id].anim, Animations[id].animParam1, Animations[id].animParam2, 0.0f);
+
+ player->rot.y = (Animations[id].forceRotation >= 0) ? Animations[id].forceRotation : direction;
+ moveSpeed = (Animations[id].forceSpeed >= 0.0f) ? Animations[id].forceSpeed : 3.0f;
+
+ if (Animations[id].repeatEffect) {
+ player->hasEffect = true;
+ player->effectName = Animations[id].repeatEffect;
+ } else {
+ player->hasEffect = false;
+ }
+
+ if (Animations[id].repeatSound != SE_NULL) {
+ player->hasSound = true;
+ player->soundName = Animations[id].repeatSound;
+ } else {
+ player->hasSound = false;
+ }
+
+ if (Animations[id].initialEffect)
+ SpawnEffect(Animations[id].initialEffect, 0, &player->pos, 0, &player->scale);
+ if (Animations[id].initialSound != SE_NULL)
+ MapSoundPlayer(SoundRelatedClass, Animations[id].initialSound, 1);
}
void dWMPathManager_c::moveThroughPath() {
@@ -506,12 +464,23 @@ void dWMPathManager_c::moveThroughPath() {
from = reverseThroughPath ? currentPath->end : currentPath->start;
to = reverseThroughPath ? currentPath->start : currentPath->end;
+ daWMPlayer_c *player = daWMPlayer_c::instance;
+
+
+ if (scaleAnimProgress >= 0) {
+ float soFar = scaleAnimProgress * (1.6f / 60.0f);
+ float sc = (currentPath->animation == dKPPath_s::ENTER_CAVE) ? (1.6f - soFar) : soFar;
+ player->scale.x = player->scale.y = player->scale.z = sc;
+
+ scaleAnimProgress--;
+ return;
+ }
+
+
Vec move = (Vec){to->x - from->x, to->y - from->y, 0};
VECNormalize(&move, &move);
VECScale(&move, &move, moveSpeed);
- daWMPlayer_c *player = daWMPlayer_c::instance;
-
if (isJumping) {
float ys = (float)from->y;
float ye = (float)to->y;