diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 273ce5f1..5e48e746 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -1,4 +1,3 @@ - /** * Behavior for bhvKoopa and bhvKoopaRaceEndpoint. * bhvKoopa includes normal, unshelled, tiny, and Koopa the Quick. @@ -116,7 +115,13 @@ void bhv_koopa_init(void) { if (o->oKoopaMovementType >= KOOPA_BP_KOOPA_THE_QUICK_BASE) { // koopa the quick - o->parentObj = cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint); + if (cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint) != NULL) { + o->parentObj = cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint); + } + else { + obj_mark_for_deletion(o); + return; + } struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->on_received_post = bhv_koopa_the_quick_on_received_post; diff --git a/src/game/behaviors/ukiki.inc.c b/src/game/behaviors/ukiki.inc.c index d425dacb..265e07e0 100644 --- a/src/game/behaviors/ukiki.inc.c +++ b/src/game/behaviors/ukiki.inc.c @@ -365,7 +365,13 @@ void ukiki_act_go_to_cage(void) { struct Object* obj; f32 latDistToCage = 0.0f; s16 yawToCage = 0; - obj = cur_obj_nearest_object_with_behavior(bhvUkikiCageChild); + if (cur_obj_nearest_object_with_behavior(bhvUkikiCageChild) != NULL) { + obj = cur_obj_nearest_object_with_behavior(bhvUkikiCageChild); + } + else { + obj_mark_for_deletion(o); + return; + } // Ultimately is checking the cage, as it points to the parent // of a dummy child object of the cage.