Synchronized all of the various platforms in WF

This commit is contained in:
MysterD 2020-08-11 23:03:13 -07:00
parent 84ef9e97c1
commit 7165d5ca64
5 changed files with 103 additions and 26 deletions

View file

@ -9,16 +9,25 @@ struct WFRotatingPlatformData sWFRotatingPlatformData[] = {
};
void bhv_wf_rotating_wooden_platform_loop(void) {
if (o->oSyncID == 0) {
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oAngleVelYaw);
network_init_object_field(o, &o->oFaceAngleYaw);
network_init_object_field(o, &o->oTimer);
}
if (o->oAction == 0) {
o->oAngleVelYaw = 0;
if (o->oTimer > 60) {
if (o->oTimer > 60 && network_owns_object(o)) {
o->oAction++;
; // needed to match
network_send_object(o);
}
} else {
o->oAngleVelYaw = 0x100;
if (o->oTimer > 126)
if (o->oTimer > 126) {
o->oAction = 0;
}
cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
}
cur_obj_rotate_face_angle_using_vel();

View file

@ -20,6 +20,15 @@ void bhv_wf_sliding_platform_init(void) {
}
o->oTimer = random_float() * 100.0f;
if (o->oSyncID == 0) {
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oMoveAngleYaw);
network_init_object_field(o, &o->oPosX);
network_init_object_field(o, &o->oForwardVel);
network_init_object_field(o, &o->oTimer);
}
}
void bhv_wf_sliding_platform_loop(void) {
@ -50,10 +59,11 @@ void bhv_wf_sliding_platform_loop(void) {
o->oPosX = o->oHomeX;
}
if (o->oTimer == 90) {
if (o->oTimer >= 90 && network_owns_object(o)) {
o->oAction = WF_SLID_BRICK_PTFM_ACT_EXTEND;
o->oForwardVel = o->oWFSlidBrickPtfmMovVel;
o->oMoveAngleYaw -= 0x8000;
network_send_object(o);
}
break;
}

View file

@ -3,8 +3,13 @@
void bhv_tower_door_loop(void) {
if (o->oTimer == 0)
o->oMoveAngleYaw -= 0x4000;
if (check_mario_attacking(0)) {
if ((o->oInteractStatus & INT_STATUS_INTERACTED) || check_mario_attacking(&gMarioStates[0])) {
obj_explode_and_spawn_coins(80.0f, 0);
create_sound_spawner(SOUND_GENERAL_WALL_EXPLOSION);
if (!(o->oInteractStatus & INT_STATUS_INTERACTED)) {
network_send_collect_item(o);
}
o->oInteractStatus &= ~INT_STATUS_INTERACTED;
}
}

View file

@ -1,15 +1,29 @@
// tower_platform.c.inc
void bhv_wf_solid_tower_platform_loop(void) {
if (o->parentObj->oAction == 3)
obj_mark_for_deletion(o);
if (o->parentObj->oAction == 1) {
cur_obj_become_tangible();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
} else if (o->parentObj->oAction > 1) {
cur_obj_become_intangible();
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
}
}
void bhv_wf_elevator_tower_platform_loop(void) {
if (o->oSyncID == 0) {
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oPosY);
network_init_object_field(o, &o->oTimer);
}
switch (o->oAction) {
case 0:
if (gMarioObject->platform == o)
if (gMarioObject->platform == o) {
o->oAction++;
network_send_object(o);
}
break;
case 1:
cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
@ -30,17 +44,35 @@ void bhv_wf_elevator_tower_platform_loop(void) {
o->oPosY -= 5.0f;
break;
}
if (o->parentObj->oAction == 3)
obj_mark_for_deletion(o);
if (o->parentObj->oAction == 1) {
cur_obj_become_tangible();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
} else if (o->parentObj->oAction > 1) {
cur_obj_become_intangible();
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
}
}
void bhv_wf_sliding_tower_platform_loop(void) {
if (o->oSyncID == 0) {
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oForwardVel);
network_init_object_field(o, &o->oPosX);
network_init_object_field(o, &o->oPosZ);
network_init_object_field(o, &o->oTimer);
}
s32 sp24 = o->oPlatformUnk110 / o->oPlatformUnk10C;
switch (o->oAction) {
case 0:
if (o->oTimer > sp24)
o->oAction++;
o->oForwardVel = -o->oPlatformUnk10C;
if (network_owns_object(o) && o->oTimer > sp24) {
o->oAction++;
network_send_object(o);
}
if (!network_owns_object(o) && o->oTimer > sp24) { o->oForwardVel = 0; }
break;
case 1:
if (o->oTimer > sp24)
@ -51,8 +83,14 @@ void bhv_wf_sliding_tower_platform_loop(void) {
cur_obj_compute_vel_xz();
o->oPosX += o->oVelX;
o->oPosZ += o->oVelZ;
if (o->parentObj->oAction == 3)
obj_mark_for_deletion(o);
if (o->parentObj->oAction == 1) {
cur_obj_become_tangible();
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
} else if (o->parentObj->oAction > 1) {
cur_obj_become_intangible();
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
}
}
void spawn_and_init_wf_platforms(s16 a, const BehaviorScript *bhv) {
@ -87,22 +125,27 @@ void spawn_wf_platform_group(void) {
}
void bhv_tower_platform_group_loop(void) {
f32 marioY = gMarioObject->oPosY;
o->oDistanceToMario = dist_between_objects(o, gMarioObject);
static u8 spawnedPlatforms = FALSE;
if (!spawnedPlatforms) { spawn_wf_platform_group(); spawnedPlatforms = TRUE; }
u8 anyPlayerInRange = FALSE;
for (int i = 0; i < MAX_PLAYERS; i++) {
if (gMarioStates[i].marioObj->oPosY > o->oHomeY - 1000.0f) { anyPlayerInRange = TRUE; }
}
switch (o->oAction) {
case 0:
if (marioY > o->oHomeY - 1000.0f)
o->oAction++;
if (anyPlayerInRange) { o->oAction++; }
break;
case 1:
spawn_wf_platform_group();
o->oAction++;
if (!anyPlayerInRange) { o->oAction++; }
break;
case 2:
if (marioY < o->oHomeY - 1000.0f)
o->oAction++;
break;
case 3:
case 4:
o->oAction++;
break;
case 5:
o->oAction = 0;
break;
}

View file

@ -15,9 +15,13 @@ struct Struct8032F34C sTumblingBridgeParams[] = {
void bhv_tumbling_bridge_platform_loop(void) {
switch (o->oAction) {
case 0:
if (gMarioObject->platform == o) {
if ((o->oInteractStatus & INT_STATUS_INTERACTED) || gMarioState[0].marioObj->platform == o) {
o->oAction++;
o->oTumblingBridgeUnkF4 = random_sign() * 0x80;
if (!(o->oInteractStatus & INT_STATUS_INTERACTED)) {
network_send_collect_item(o);
}
o->oInteractStatus &= ~INT_STATUS_INTERACTED;
}
break;
case 1:
@ -82,10 +86,13 @@ void tumbling_bridge_act_1(void) {
}
void tumbling_bridge_act_2(void) {
struct Object* player = nearest_player_to_object(o);
int distanceToPlayer = dist_between_objects(o, player);
cur_obj_hide();
if (cur_obj_has_behavior(bhvLllTumblingBridge))
cur_obj_unhide();
else if (o->oDistanceToMario > 1200.0f) {
else if (distanceToPlayer > 1200.0f) {
o->oAction = 3;
cur_obj_unhide();
}
@ -97,7 +104,10 @@ void tumbling_bridge_act_3(void) {
}
void tumbling_bridge_act_0(void) {
if (cur_obj_has_behavior(bhvLllTumblingBridge) || o->oDistanceToMario < 1000.0f)
struct Object* player = nearest_player_to_object(o);
int distanceToPlayer = dist_between_objects(o, player);
if (cur_obj_has_behavior(bhvLllTumblingBridge) || distanceToPlayer < 1000.0f)
o->oAction = 1;
}