Remove player's bubble when they leave the area

This commit is contained in:
MysterD 2022-03-29 18:17:37 -07:00
parent 0a5d4cd215
commit bc11f06136
4 changed files with 20 additions and 3 deletions

View File

@ -91,7 +91,7 @@ void bhv_bubble_player_loop(void) {
o->header.gfx.scale[2] = scale;
// check if the bubble popped
if (marioState->action != ACT_BUBBLED) {
if (marioState->action != ACT_BUBBLED || !is_player_in_local_area(marioState)) {
spawn_mist_particles();
create_sound_spawner(SOUND_OBJ_DIVING_IN_WATER);
marioState->bubbleObj = NULL;

View File

@ -952,8 +952,7 @@ s32 act_bubbled(struct MarioState* m) {
}
// create bubble
if (m->bubbleObj == NULL) {
//m->bubbleObj = spawn_object(m->marioObj, MODEL_BUBBLE, bhvBubblePlayer);
if (m->bubbleObj == NULL && is_player_in_local_area(m)) {
m->bubbleObj = spawn_object(m->marioObj, MODEL_BUBBLE_PLAYER, bhvBubblePlayer);
if (m->bubbleObj != NULL) {
m->bubbleObj->heldByPlayerIndex = m->playerIndex;

View File

@ -536,6 +536,23 @@ u8 is_player_active(struct MarioState* m) {
return TRUE;
}
u8 is_player_in_local_area(struct MarioState* m) {
if (gNetworkType == NT_NONE && m == &gMarioStates[0]) { return TRUE; }
struct NetworkPlayer* np = &gNetworkPlayers[m->playerIndex];
if (np == gNetworkPlayerServer && gServerSettings.headlessServer) { return FALSE; }
if (np->type != NPT_LOCAL) {
if (!np->connected) { return FALSE; }
if (gNetworkPlayerLocal == NULL) { return FALSE; }
bool levelAreaMismatch =
(np->currCourseNum != gNetworkPlayerLocal->currCourseNum
|| np->currActNum != gNetworkPlayerLocal->currActNum
|| np->currLevelNum != gNetworkPlayerLocal->currLevelNum
|| np->currAreaIndex != gNetworkPlayerLocal->currAreaIndex);
if (levelAreaMismatch) { return FALSE; }
}
return TRUE;
}
/**
* Returns closest MarioState
*/

View File

@ -163,6 +163,7 @@ void bhv_rr_cruiser_wing_init(void);
void bhv_rr_cruiser_wing_loop(void);
struct Object* spawn_default_star(f32 sp20, f32 sp24, f32 sp28);
u8 is_player_active(struct MarioState* m);
u8 is_player_in_local_area(struct MarioState* m);
struct MarioState* nearest_mario_state_to_object(struct Object* obj);
struct Object* nearest_player_to_object(struct Object* obj);
u8 is_nearest_mario_state_to_object(struct MarioState* m, struct Object* obj);