Path: blob/master/src/game/behaviors/arrow_lift.inc.c
7861 views
/**1* Behavior for WDW arrow lifts.2* When a player stands on an arrow lift, it starts moving between3* two positions 384 units apart.4* Arrow lifts move either along the X axis or the Z axis.5* Their facing angle is always perpendicular to the axis they move on.6* The angle the arrow lifts move initially is 90º clockwise of the face angle.7* This means an arrow lift at (0, 0, 0) with face angle 0 (positive Z) will8* move between (0, 0, 0) and (-384, 0, 0).9*/1011/**12* Move the arrow lift away from its original position.13*/14static s32 arrow_lift_move_away(void) {15s8 status = ARROW_LIFT_NOT_DONE_MOVING;1617o->oMoveAngleYaw = o->oFaceAngleYaw - 0x4000;18o->oVelY = 0;19o->oForwardVel = 12;20// Cumulative displacement is used to keep track of how far the platform21// has travelled, so that it can stop.22o->oArrowLiftDisplacement += o->oForwardVel;2324// Stop the platform after moving 384 units.25if (o->oArrowLiftDisplacement > 384) {26o->oForwardVel = 0;27o->oArrowLiftDisplacement = 384;28status = ARROW_LIFT_DONE_MOVING;29}3031obj_move_xyz_using_fvel_and_yaw(o);32return status;33}3435/**36* Move the arrow lift back to its original position.37*/38static s8 arrow_lift_move_back(void) {39s8 status = ARROW_LIFT_NOT_DONE_MOVING;4041o->oMoveAngleYaw = o->oFaceAngleYaw + 0x4000;42o->oVelY = 0;43o->oForwardVel = 12;44o->oArrowLiftDisplacement -= o->oForwardVel;4546// Stop the platform after returning back to its original position.47if (o->oArrowLiftDisplacement < 0) {48o->oForwardVel = 0;49o->oArrowLiftDisplacement = 0;50status = ARROW_LIFT_DONE_MOVING;51}5253obj_move_xyz_using_fvel_and_yaw(o);54return status;55}5657/**58* Arrow lift update function.59*/60void bhv_arrow_lift_loop(void) {61switch (o->oAction) {62case ARROW_LIFT_ACT_IDLE:63// Wait 61 frames before moving.64if (o->oTimer > 60) {65if (gMarioObject->platform == o) {66o->oAction = ARROW_LIFT_ACT_MOVING_AWAY;67}68}6970break;7172case ARROW_LIFT_ACT_MOVING_AWAY:73if (arrow_lift_move_away() == ARROW_LIFT_DONE_MOVING) {74o->oAction = ARROW_LIFT_ACT_MOVING_BACK;75}7677break;7879case ARROW_LIFT_ACT_MOVING_BACK:80// Wait 61 frames before moving (after stopping after moving forwards).81if (o->oTimer > 60) {82if (arrow_lift_move_back() == ARROW_LIFT_DONE_MOVING) {83o->oAction = ARROW_LIFT_ACT_IDLE;84}85}8687break;88}89}909192