Synchronized kickable board

This commit is contained in:
MysterD 2020-08-11 23:02:03 -07:00
parent 0e72fc2b1f
commit aec993b5b6
1 changed files with 30 additions and 13 deletions

View File

@ -1,19 +1,19 @@
// kickable_board.c.inc // kickable_board.c.inc
s32 check_mario_attacking(UNUSED s32 sp18) { s32 check_mario_attacking(struct MarioState* marioState) {
if (obj_check_if_collided_with_object(o, gMarioObject)) { if (obj_check_if_collided_with_object(o, marioState->marioObj)) {
if (abs_angle_diff(o->oMoveAngleYaw, gMarioObject->oMoveAngleYaw) > 0x6000) { if (abs_angle_diff(o->oMoveAngleYaw, marioState->marioObj->oMoveAngleYaw) > 0x6000) {
if (gMarioStates->action == ACT_SLIDE_KICK) if (marioState->action == ACT_SLIDE_KICK)
return 1; return 1;
if (gMarioStates->action == ACT_PUNCHING) if (marioState->action == ACT_PUNCHING)
return 1; return 1;
if (gMarioStates->action == ACT_MOVE_PUNCHING) if (marioState->action == ACT_MOVE_PUNCHING)
return 1; return 1;
if (gMarioStates->action == ACT_SLIDE_KICK_SLIDE) if (marioState->action == ACT_SLIDE_KICK_SLIDE)
return 1; return 1;
if (gMarioStates->action == ACT_JUMP_KICK) if (marioState->action == ACT_JUMP_KICK)
return 2; return 2;
if (gMarioStates->action == ACT_WALL_KICK_AIR) if (marioState->action == ACT_WALL_KICK_AIR)
return 2; return 2;
} }
} }
@ -26,13 +26,26 @@ void init_kickable_board_rock(void) {
} }
void bhv_kickable_board_loop(void) { void bhv_kickable_board_loop(void) {
struct MarioState* marioState = nearest_mario_state_to_object(o);
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->oAngleVelPitch);
network_init_object_field(o, &o->oFaceAnglePitch);
network_init_object_field(o, &o->oKickableBoardF4);
network_init_object_field(o, &o->oKickableBoardF8);
network_init_object_field(o, &o->oMoveAngleYaw);
network_init_object_field(o, &o->oPosY);
network_init_object_field(o, &o->oTimer);
}
s32 sp24; s32 sp24;
switch (o->oAction) { switch (o->oAction) {
case 0: case 0:
o->oFaceAnglePitch = 0; o->oFaceAnglePitch = 0;
if (check_mario_attacking(0)) { if (check_mario_attacking(marioState)) {
init_kickable_board_rock(); init_kickable_board_rock();
o->oAction++; o->oAction++;
if (network_owns_object(o)) { network_send_object(o); }
} }
load_object_collision_model(); load_object_collision_model();
break; break;
@ -40,17 +53,20 @@ void bhv_kickable_board_loop(void) {
o->oFaceAnglePitch = 0; o->oFaceAnglePitch = 0;
load_object_collision_model(); load_object_collision_model();
o->oFaceAnglePitch = -sins(o->oKickableBoardF4) * o->oKickableBoardF8; o->oFaceAnglePitch = -sins(o->oKickableBoardF4) * o->oKickableBoardF8;
if (o->oTimer > 30 && (sp24 = check_mario_attacking(0))) { if (o->oTimer > 30 && (sp24 = check_mario_attacking(marioState))) {
if (gMarioObject->oPosY > o->oPosY + 160.0f && sp24 == 2) { if (marioState->marioObj->oPosY > o->oPosY + 160.0f && sp24 == 2) {
o->oAction++; o->oAction++;
cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2); cur_obj_play_sound_2(SOUND_GENERAL_BUTTON_PRESS_2);
if (network_owns_object(o)) { network_send_object(o); }
} else } else
o->oTimer = 0; o->oTimer = 0;
} }
if (o->oTimer != 0) { if (o->oTimer != 0) {
o->oKickableBoardF8 -= 8; o->oKickableBoardF8 -= 8;
if (o->oKickableBoardF8 < 0) if (o->oKickableBoardF8 < 0) {
o->oAction = 0; o->oAction = 0;
if (network_owns_object(o)) { network_send_object(o); }
}
} else } else
init_kickable_board_rock(); init_kickable_board_rock();
if (!(o->oKickableBoardF4 & 0x7FFF)) if (!(o->oKickableBoardF4 & 0x7FFF))
@ -68,6 +84,7 @@ void bhv_kickable_board_loop(void) {
o->oAction++; o->oAction++;
cur_obj_shake_screen(SHAKE_POS_SMALL); cur_obj_shake_screen(SHAKE_POS_SMALL);
cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4); cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4);
if (network_owns_object(o)) { network_send_object(o); }
} }
load_object_collision_model(); load_object_collision_model();
break; break;