summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kamek_pal.x2
-rw-r--r--magicplatform.yaml2
-rw-r--r--src/magicplatform.cpp100
3 files changed, 102 insertions, 2 deletions
diff --git a/kamek_pal.x b/kamek_pal.x
index 48bebf2..3dedcab 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -1487,6 +1487,8 @@ SECTIONS {
SpawnThwompEffects = 0x809f6660;
+ HurtMarioBecauseOfBeingSquashed = 0x80056370;
+
.text : {
FILL (0)
diff --git a/magicplatform.yaml b/magicplatform.yaml
index 69b349c..df98819 100644
--- a/magicplatform.yaml
+++ b/magicplatform.yaml
@@ -11,5 +11,5 @@ hooks:
addr_pal: 0x8030BDA8
# -ID- ---- -X Offs- -Y Offs- -RectX1- -RectY1- -RectX2- -RectY2- -1C- -1E- -20- -22- Flag ----
# Orig 00C4 0000 00000008 FFFFFFF0 00000000 00000010 00000010 00000010 0000 0000 0000 0000 0000 0000
- data: '00C4 0000 00000000 00000000 00000000 00000000 00000100 00000100 0000 0000 0000 0000 0000 0000'
+ data: '00C4 0000 00000000 00000000 00000000 00000000 00000100 00000100 0000 0000 0000 0000 0002 0000'
diff --git a/src/magicplatform.cpp b/src/magicplatform.cpp
index 924d849..e9fa940 100644
--- a/src/magicplatform.cpp
+++ b/src/magicplatform.cpp
@@ -12,6 +12,10 @@ class daEnMagicPlatform_c : public dEn_c {
// Settings
u8 rectID, moveSpeed, moveDirection, moveLength;
+ u8 moveDelay, currentMoveDelay;
+
+ bool doesMoveInfinitely;
+
float moveMin, moveMax, moveDelta, moveBaseDelta;
float *moveTarget;
@@ -41,12 +45,87 @@ daEnMagicPlatform_c *daEnMagicPlatform_c::build() {
return c;
}
+extern "C" void HurtMarioBecauseOfBeingSquashed(void *mario, dStageActor_c *squasher, int type);
+
+static void PhysCB1(daEnMagicPlatform_c *one, dStageActor_c *two) {
+ if (two->stageActorType != 1)
+ return;
+
+ // if left/right
+ if (one->moveDirection <= 1)
+ return;
+
+ if (one->pos_delta.y > 0.0f)
+ HurtMarioBecauseOfBeingSquashed(two, one, 1);
+ else
+ HurtMarioBecauseOfBeingSquashed(two, one, 9);
+}
+
+static void PhysCB2(daEnMagicPlatform_c *one, dStageActor_c *two) {
+ if (two->stageActorType != 1)
+ return;
+
+ // if left/right
+ if (one->moveDirection <= 1)
+ return;
+
+ if (one->pos_delta.y < 0.0f)
+ HurtMarioBecauseOfBeingSquashed(two, one, 2);
+ else
+ HurtMarioBecauseOfBeingSquashed(two, one, 10);
+}
+
+static void PhysCB3(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) {
+ if (two->stageActorType != 1)
+ return;
+
+ // if left/right
+ if (one->moveDirection <= 1)
+ return;
+
+ if (unkMaybeNotBool) {
+ if (one->pos_delta.x > 0.0f)
+ HurtMarioBecauseOfBeingSquashed(two, one, 6);
+ else
+ HurtMarioBecauseOfBeingSquashed(two, one, 12);
+ } else {
+ if (one->pos_delta.x < 0.0f)
+ HurtMarioBecauseOfBeingSquashed(two, one, 5);
+ else
+ HurtMarioBecauseOfBeingSquashed(two, one, 11);
+ }
+}
+
+static bool PhysCB4(daEnMagicPlatform_c *one, dStageActor_c *two) {
+ return (one->pos_delta.y > 0.0f);
+}
+
+static bool PhysCB5(daEnMagicPlatform_c *one, dStageActor_c *two) {
+ return (one->pos_delta.y < 0.0f);
+}
+
+static bool PhysCB6(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) {
+ if (unkMaybeNotBool) {
+ if (one->pos_delta.x > 0.0f)
+ return true;
+ } else {
+ if (one->pos_delta.x < 0.0f)
+ return true;
+ }
+ return false;
+}
+
int daEnMagicPlatform_c::onCreate() {
rectID = settings & 0xFF;
+
moveSpeed = (settings & 0xF00) >> 8;
moveDirection = (settings & 0x3000) >> 12;
moveLength = ((settings & 0xF0000) >> 16) + 1;
+ moveDelay = ((settings & 0xF00000) >> 20) * 6;
+
+ doesMoveInfinitely = (settings & 0x10000000);
+
setupMovement();
findSourceArea();
@@ -56,7 +135,11 @@ int daEnMagicPlatform_c::onCreate() {
float fHeight = height * 16.0f;
physics.setup(this,
0.0f, 0.0f, fWidth, -fHeight,
- 0, 0, 0/*&PhysCB1, &PhysCB2, &PhysCB3*/, 1, 0, 0);
+ &PhysCB1, &PhysCB2, &PhysCB3, 1, 0, 0);
+
+ physics.callback1 = &PhysCB4;
+ physics.callback2 = &PhysCB5;
+ physics.callback3 = &PhysCB6;
physics.addToList();
@@ -77,6 +160,9 @@ int daEnMagicPlatform_c::onExecute() {
updateTilePositions();
physics.update();
+ if (doesMoveInfinitely)
+ checkZoneBoundaries(0);
+
return 1;
}
@@ -119,6 +205,8 @@ void daEnMagicPlatform_c::setupMovement() {
} else {
isMoving = false;
}
+
+ currentMoveDelay = 0;
}
void daEnMagicPlatform_c::handleMovement() {
@@ -145,12 +233,21 @@ void daEnMagicPlatform_c::handleMovement() {
if (!isMoving)
return;
+ if (currentMoveDelay > 0) {
+ currentMoveDelay--;
+ return;
+ }
+
// Do it
bool goesForward = (moveDelta > 0.0f);
bool reachedEnd = false;
*moveTarget += moveDelta;
+ // if we're set to move infinitely, never stop
+ if (doesMoveInfinitely)
+ return;
+
if (goesForward) {
if (*moveTarget >= moveMax) {
*moveTarget = moveMax;
@@ -175,6 +272,7 @@ void daEnMagicPlatform_c::handleMovement() {
} else {
// Otherwise, reverse
moveDelta = -moveDelta;
+ currentMoveDelay = moveDelay;
}
}
}