diff --git a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c index db864d403..da860cb21 100644 --- a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -213,6 +213,16 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { return sp64; } +// Presumably, due to the removal of object dependency, there is a race condition where +// the GS on the Kak construction site spawns to early and fails to detect the +// construction site dyna poly. This custom action func rechecks moving the GS +// to the nearest poly one frame after init. Further explanation available: +// https://github.com/HarbourMasters/Shipwright/issues/2310#issuecomment-1492829517 +void EnSw_MoveGoldLater(EnSw* this, PlayState* play) { + func_80B0C0CC(this, play, 1); + this->actionFunc = func_80B0D590; +} + void EnSw_Init(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; s32 phi_v0; @@ -304,6 +314,14 @@ void EnSw_Init(Actor* thisx, PlayState* play) { } else { this->actionFunc = func_80B0D590; } + + // If a normal GS failed to get attached to a poly during init + // try once more on the next frame via a custom action func + if ((((thisx->params & 0xE000) >> 0xD) == 1 || + ((thisx->params & 0xE000) >> 0xD) == 2) && + this->actor.floorPoly == NULL) { + this->actionFunc = EnSw_MoveGoldLater; + } } void EnSw_Destroy(Actor* thisx, PlayState* play) {