Fix common enemy rando crashes (#2242)

This commit is contained in:
aMannus 2022-12-24 04:25:38 +01:00 committed by GitHub
parent 6eaf51c2bd
commit 07bae6b84c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3326,6 +3326,15 @@ Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play
return NULL;
}
// The following enemies break when the parent actor isn't the same as what would happen in authentic gameplay.
// As such, don't assign a parent to them at all when spawned with Enemy Randomizer.
// Gohma (z_boss_goma.c), the Stalchildren spawner (z_en_encount1.c) and the falling platform spawning Stalfos in
// Forest Temple (z_bg_mori_bigst.c) that normally rely on this behaviour are changed when
// Enemy Rando is on so they still work properly even without assigning a parent.
if (CVar_GetS32("gRandomizedEnemies", 0) && (spawnedActor->id == ACTOR_EN_FLOORMAS || spawnedActor->id == ACTOR_EN_PEEHAT)) {
return spawnedActor;
}
parent->child = spawnedActor;
spawnedActor->parent = parent;