Fix 100 coin stars spawning inside ceilings + being able to spawn multiple 100 coin stars (#541)

* Going below 100 coins and getting 100 coins again will no longer result in multiple 100 coin stars spawning

* 100 coin stars can no longer clip into ceilings

* Renamed set_home_to_mario to spawned_star_set_target_above_mario since it's a more descriptive name of what it does
This commit is contained in:
Reonu
2022-12-06 18:44:16 +01:00
committed by GitHub
parent 1098ea95ea
commit 22b3c9ba08
4 changed files with 16 additions and 4 deletions

View File

@@ -36,11 +36,17 @@ void set_sparkle_spawn_star_hitbox(void) {
}
}
void set_home_to_mario(void) {
void spawned_star_set_target_above_mario(void) {
vec3f_copy_y_off(&o->oHomeVec, &gMarioObject->oPosVec, 250.0f);
o->oPosY = o->oHomeY;
// Check that the star isn't clipping inside the ceiling
if (gMarioState->ceil != NULL) {
if (o->oHomeY > (gMarioState->ceilHeight - 50)) {
o->oHomeY = gMarioState->ceilHeight - 50;
}
}
o->oPosY = o->oHomeY;
f32 lateralDist;
vec3f_get_lateral_dist(&o->oPosVec, &o->oHomeVec, &lateralDist);
@@ -66,7 +72,7 @@ void bhv_spawned_star_loop(void) {
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oAngleVelYaw = 0x800;
if (o->oBehParams2ndByte == SPAWN_STAR_POS_CUTSCENE_BP_SPAWN_AT_MARIO) {
set_home_to_mario();
spawned_star_set_target_above_mario();
} else {
set_y_home_to_pos();
}

View File

@@ -737,8 +737,9 @@ u32 interact_coin(struct MarioState *m, UNUSED u32 interactType, struct Object *
#ifdef X_COIN_STAR
if (COURSE_IS_MAIN_COURSE(gCurrCourseNum) && m->numCoins - obj->oDamageOrCoinValue < X_COIN_STAR
&& m->numCoins >= X_COIN_STAR) {
&& m->numCoins >= X_COIN_STAR && !g100CoinStarSpawned) {
bhv_spawn_star_no_level_exit(STAR_BP_ACT_100_COINS);
g100CoinStarSpawned = TRUE;
}
#endif
#if ENABLE_RUMBLE

View File

@@ -141,6 +141,8 @@ s16 sSourceWarpNodeId;
s32 sDelayedWarpArg;
s8 sTimerRunning;
s8 gNeverEnteredCastle;
// Prevent multiple 100 coin stars from spawning
u8 g100CoinStarSpawned = FALSE;
struct MarioState *gMarioState = &gMarioStates[0];
s8 sWarpCheckpointActive = FALSE;
@@ -1173,6 +1175,8 @@ s32 init_level(void) {
sTransitionTimer = 0;
sSpecialWarpDest = WARP_SPECIAL_NONE;
g100CoinStarSpawned = FALSE;
if (gCurrCreditsEntry == NULL) {
gHudDisplay.flags = HUD_DISPLAY_DEFAULT;
} else {

View File

@@ -122,6 +122,7 @@ struct HudDisplay {
extern struct HudDisplay gHudDisplay;
extern s8 gNeverEnteredCastle;
extern u8 g100CoinStarSpawned;
enum HUDDisplayFlag {
HUD_DISPLAY_FLAG_LIVES = (1 << 0), // 0x0001