Path: blob/master/src/game/behaviors/bbh_tilting_trap.inc.c
7861 views
/**1* Behavior for bhvBbhTiltingTrapPlatform.2* This is the tilting platform trap in the upper floor of BBH3* that drops the player into the merry-go-round area.4*/56/**7* Update function for bhvBbhTiltingTrapPlatform.8*/9void bhv_bbh_tilting_trap_platform_loop(void) {10UNUSED s32 unused;1112// US (and probably later) versions use oAction for the13// if statement, while immediately setting it over here.14// This was done so that Mario leaving or getting on the platform15// resets oTimer to 0.16#ifndef VERSION_JP17if (gMarioObject->platform == o) {18o->oAction = BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON;19} else {20o->oAction = BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_OFF;21}2223if (o->oAction == BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON) {24#else25if (gMarioObject->platform == o) {26#endif27o->oAngleVelPitch = (s32)(o->oDistanceToMario * coss(o->oAngleToMario));28o->oFaceAnglePitch += o->oAngleVelPitch;29} else30#ifndef VERSION_JP31// In the US version, if the platform has tilted more than 3000 angle units32// in less than 16 frames since Mario got on it, and he has stepped off,33// this code will not run, so it will continue to rotate with the same34// angular velocity for 16 more frames. This was probably done to make35// the platform more dangerous. This code will not work correctly36// without the oAction changes above, since oTimer will not ever37// reset to 0 without them.38if ((absi(o->oFaceAnglePitch) < 3000) || (o->oTimer >= 16))39#endif40{41// Make the platform return to the horizontal at a speed of42// 200 angle units/frame, and clamp it to 0 if it's within 200 units of 0.43o->oAngleVelPitch = 0;4445if ((s16) o->oFaceAnglePitch > 0) {46if (o->oFaceAnglePitch < 200) {47o->oFaceAnglePitch = 0;48} else {49o->oAngleVelPitch = -200;50}51} else {52if (o->oFaceAnglePitch > -200) {53o->oFaceAnglePitch = 0;54} else {55o->oAngleVelPitch = 200;56}57}58}5960// Update angle61o->oFaceAnglePitch += o->oAngleVelPitch;62}636465