diff --git a/data/behavior_data.c b/data/behavior_data.c index 5dd06103..cb1bb8b1 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -1803,6 +1803,15 @@ const BehaviorScript bhvAnotherTiltingPlatform[] = { END_LOOP(), }; +const BehaviorScript bhvSquarishPathParent[] = { + BEGIN(OBJ_LIST_SURFACE), + ID(id_bhvSquarishPathParent), + CALL_NATIVE(bhv_squarish_path_parent_init), + BEGIN_LOOP(), + CALL_NATIVE(bhv_squarish_path_parent_loop), + END_LOOP(), +}; + const BehaviorScript bhvSquarishPathMoving[] = { BEGIN(OBJ_LIST_SURFACE), ID(id_bhvSquarishPathMoving), diff --git a/data/behavior_table.c b/data/behavior_table.c index 806e1765..d26846cd 100644 --- a/data/behavior_table.c +++ b/data/behavior_table.c @@ -124,6 +124,7 @@ const BehaviorScript* gBehaviorTable[id_bhv_max_count] = { [id_bhvTreeLeaf] = bhvTreeLeaf, [id_bhvAnotherTiltingPlatform] = bhvAnotherTiltingPlatform, [id_bhvSquarishPathMoving] = bhvSquarishPathMoving, + [id_bhvSquarishPathParent] = bhvSquarishPathParent, [id_bhvPiranhaPlantBubble] = bhvPiranhaPlantBubble, [id_bhvPiranhaPlantWakingBubbles] = bhvPiranhaPlantWakingBubbles, [id_bhvFloorSwitchAnimatesObject] = bhvFloorSwitchAnimatesObject, diff --git a/include/behavior_data.h b/include/behavior_data.h index b5e6d073..6ec2c741 100644 --- a/include/behavior_data.h +++ b/include/behavior_data.h @@ -128,6 +128,7 @@ extern const BehaviorScript bhvTreeSnow[]; extern const BehaviorScript bhvTreeLeaf[]; extern const BehaviorScript bhvAnotherTiltingPlatform[]; extern const BehaviorScript bhvSquarishPathMoving[]; +extern const BehaviorScript bhvSquarishPathParent[]; extern const BehaviorScript bhvPiranhaPlantBubble[]; extern const BehaviorScript bhvPiranhaPlantWakingBubbles[]; extern const BehaviorScript bhvFloorSwitchAnimatesObject[]; diff --git a/include/behavior_table.h b/include/behavior_table.h index facc9a91..05fbf542 100644 --- a/include/behavior_table.h +++ b/include/behavior_table.h @@ -128,6 +128,7 @@ enum BehaviorId { id_bhvTreeLeaf, id_bhvAnotherTiltingPlatform, id_bhvSquarishPathMoving, + id_bhvSquarishPathParent, id_bhvPiranhaPlantBubble, id_bhvPiranhaPlantWakingBubbles, id_bhvFloorSwitchAnimatesObject, diff --git a/levels/bitdw/script.c b/levels/bitdw/script.c index 77297c36..7d52e538 100644 --- a/levels/bitdw/script.c +++ b/levels/bitdw/script.c @@ -17,12 +17,9 @@ #include "levels/bitdw/header.h" static const LevelScript script_func_local_1[] = { - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -1966, -3154, 3586, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathMoving), - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -1352, -3154, 4200, /*angle*/ 0, 0, 0, /*behParam*/ 0x00020000, /*beh*/ bhvSquarishPathMoving), - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -2963, 1017, -2464, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathMoving), - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -2349, 1017, -1849, /*angle*/ 0, 0, 0, /*behParam*/ 0x00020000, /*beh*/ bhvSquarishPathMoving), - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -2349, 1017, -1235, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathMoving), - OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -1735, 1017, -621, /*angle*/ 0, 0, 0, /*behParam*/ 0x00020000, /*beh*/ bhvSquarishPathMoving), + OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -1966, -3154, 3586, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathParent), + OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -2963, 1017, -2464, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathParent), + OBJECT(/*model*/ MODEL_BITDW_SQUARE_PLATFORM, /*pos*/ -2349, 1017, -1235, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSquarishPathParent), OBJECT(/*model*/ MODEL_BITDW_SEESAW_PLATFORM, /*pos*/ 1491, 1273, 512, /*angle*/ 0, 90, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSeesawPlatform), OBJECT(/*model*/ MODEL_BITDW_SEESAW_PLATFORM, /*pos*/ -147, 894, 512, /*angle*/ 0, 90, 0, /*behParam*/ 0x00000000, /*beh*/ bhvSeesawPlatform), OBJECT(/*model*/ MODEL_BITDW_SLIDING_PLATFORM, /*pos*/ -5728, 819, -2151, /*angle*/ 0, 0, 0, /*behParam*/ 0x03CE0000, /*beh*/ bhvSlidingPlatform2), diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h index 46600eb1..a67ba829 100644 --- a/src/game/behavior_actions.h +++ b/src/game/behavior_actions.h @@ -131,6 +131,8 @@ void bhv_small_water_wave_loop(void); void bhv_yellow_coin_init(void); void bhv_yellow_coin_loop(void); void bhv_squarish_path_moving_loop(void); +void bhv_squarish_path_parent_init(void); +void bhv_squarish_path_parent_loop(void); void bhv_heave_ho_loop(void); void bhv_heave_ho_throw_mario_loop(void); void bhv_ccm_touched_star_spawn_loop(void); diff --git a/src/game/behaviors/square_platform_cycle.inc.c b/src/game/behaviors/square_platform_cycle.inc.c index 24eacb02..3abc8c08 100644 --- a/src/game/behaviors/square_platform_cycle.inc.c +++ b/src/game/behaviors/square_platform_cycle.inc.c @@ -1,5 +1,41 @@ // square_platform_cycle.c.inc +void bhv_squarish_path_parent_init(void) { + o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; + cur_obj_become_intangible(); + + static s16 radius = (614 / 2); + o->oPosX += radius; + o->oPosZ += radius; + + struct SyncObject* so = network_init_object(o, 2000.0f); + so->hasStandardFields = FALSE; + so->maxUpdateRate = 5.0f; + + for (int i = 0; i < 2; i++) { + s16 action = (i == 0) ? 1 : 3; + s16 offset = (i == 0) ? (-radius) : (radius); + struct Object* square = spawn_object(o, MODEL_BITDW_SQUARE_PLATFORM, bhvSquarishPathMoving); + square->oPosX = o->oPosX + offset; + square->oPosY = o->oPosY; + square->oPosZ = o->oPosZ + offset; + square->oAction = action; + network_init_object_field(o, &square->oMoveAngleYaw); + network_init_object_field(o, &square->oForwardVel); + network_init_object_field(o, &square->oPosX); + network_init_object_field(o, &square->oPosY); + network_init_object_field(o, &square->oPosZ); + network_init_object_field(o, &square->oVelX); + network_init_object_field(o, &square->oVelY); + network_init_object_field(o, &square->oVelZ); + network_init_object_field(o, &square->oAction); + network_init_object_field(o, &square->oPrevAction); + network_init_object_field(o, &square->oTimer); + } +} + +void bhv_squarish_path_parent_loop(void) { } + s32 square_plat_set_yaw_until_timer(u16 yaw, s32 a) { o->oMoveAngleYaw = yaw; if (a < o->oTimer)