From d1c56b60a322f3ea08af3188680f4a8384eb80fd Mon Sep 17 00:00:00 2001 From: mineqwerty Date: Mon, 5 Jun 2023 18:28:13 -0400 Subject: [PATCH] fixed spawning bug with level red coin stars --- README.md | 3 +-- src/game/behaviors/hidden_star.inc.c | 3 +-- src/game/behaviors/spawn_star.inc.c | 18 +++++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7edbec19..ff78e89e 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,7 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff - Use `render_multi_image` to draw large texture rectangles consisting of multiple images on the screen. - More info in `puppyprint.c` - Wiseguy's Farcall TLB mapping allows to store executable code inside uncompressed segments, that can be loaded and ran as needed, instead of it having to be loaded at all times. See `farcall.h` in the include folder for instructions and details. -- Red Coin Stars now support up to 99 red coins! You can have red coin stars specific to areas, or you can use the hidden red coin star's 2nd behavior param to set a red coin -count required to spawn the star. +- Red Coin Stars now support up to 99 red coins! You can have red coin stars specific to areas, or you can use the hidden red coin star's 2nd behavior param to set a red coin count required to spawn the star. # UltraSM64 diff --git a/src/game/behaviors/hidden_star.inc.c b/src/game/behaviors/hidden_star.inc.c index 06f5c2b8..d41752b0 100644 --- a/src/game/behaviors/hidden_star.inc.c +++ b/src/game/behaviors/hidden_star.inc.c @@ -48,13 +48,12 @@ void bhv_hidden_star_trigger_loop(void) { } void bhv_bowser_course_red_coin_star_init(void) { - s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin); - if (o->oBehParams2ndByte != 0) { o->oHiddenStarTriggerTotal = o->oBehParams2ndByte; o->oHiddenStarTriggerCounter = gRedCoinsCollected; } else { + s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin); o->oHiddenStarTriggerTotal = numRedCoinsRemaining + gRedCoinsCollected; o->oHiddenStarTriggerCounter = o->oHiddenStarTriggerTotal - numRedCoinsRemaining; } diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 6fbc6fac..b8529e3f 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -157,18 +157,22 @@ void bhv_hidden_red_coin_star_init(void) { spawn_object(o, MODEL_TRANSPARENT_STAR, bhvRedCoinStarMarker); } - s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin); - if (numRedCoinsRemaining == 0) { - starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); - starObj->oBehParams = o->oBehParams; - o->activeFlags = ACTIVE_FLAG_DEACTIVATED; - } - if (o->oBehParams2ndByte != 0) { o->oHiddenStarTriggerTotal = o->oBehParams2ndByte; o->oHiddenStarTriggerCounter = gRedCoinsCollected; + if (o->oHiddenStarTriggerCounter >= o->oHiddenStarTriggerTotal) { + starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); + starObj->oBehParams = o->oBehParams; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } } else { + s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin); + if (numRedCoinsRemaining == 0) { + starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); + starObj->oBehParams = o->oBehParams; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + } o->oHiddenStarTriggerTotal = numRedCoinsRemaining + gRedCoinsCollected; o->oHiddenStarTriggerCounter = o->oHiddenStarTriggerTotal - numRedCoinsRemaining; }