You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
spawn_star.inc.c improvements
This commit is contained in:
@@ -15,15 +15,12 @@ static struct ObjectHitbox sCollectStarHitbox = {
|
||||
};
|
||||
|
||||
void bhv_collect_star_init(void) {
|
||||
s8 starId;
|
||||
u8 currentLevelStarFlags;
|
||||
|
||||
starId = (o->oBehParams >> 24) & 0xFF;
|
||||
s8 starId = (o->oBehParams >> 24) & 0xFF;
|
||||
#ifdef GLOBAL_STAR_IDS
|
||||
currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, (starId/7) - 1);
|
||||
u8 currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, (starId/7) - 1);
|
||||
if (currentLevelStarFlags & (1 << (starId % 7))) {
|
||||
#else
|
||||
currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1);
|
||||
u8 currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1);
|
||||
if (currentLevelStarFlags & (1 << starId)) {
|
||||
#endif
|
||||
o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_TRANSPARENT_STAR];
|
||||
@@ -39,20 +36,27 @@ void bhv_collect_star_loop(void) {
|
||||
|
||||
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
|
||||
obj_mark_for_deletion(o);
|
||||
o->oInteractStatus = 0;
|
||||
o->oInteractStatus = INT_STATUS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void bhv_star_spawn_init(void) {
|
||||
o->oMoveAngleYaw = atan2s(o->oHomeZ - o->oPosZ, o->oHomeX - o->oPosX);
|
||||
o->oStarSpawnDisFromHome = sqrtf(sqr(o->oHomeX - o->oPosX) + sqr(o->oHomeZ - o->oPosZ));
|
||||
f32 dx = (o->oHomeX - o->oPosX);
|
||||
f32 dz = (o->oHomeZ - o->oPosZ);
|
||||
o->oMoveAngleYaw = atan2s(dz, dx);
|
||||
o->oStarSpawnDisFromHome = sqrtf(sqr(dx) + sqr(dz));
|
||||
o->oVelY = (o->oHomeY - o->oPosY) / 30.0f;
|
||||
o->oForwardVel = o->oStarSpawnDisFromHome / 30.0f;
|
||||
o->oStarSpawnVelY = o->oPosY;
|
||||
if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH)
|
||||
#ifdef DISABLE_LEVEL_SPECIFIC_CHECKS
|
||||
if (o->oBehParams2ndByte == 0) {
|
||||
#else
|
||||
if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH) {
|
||||
#endif
|
||||
cutscene_object(CUTSCENE_STAR_SPAWN, o);
|
||||
else
|
||||
} else {
|
||||
cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o);
|
||||
}
|
||||
|
||||
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
|
||||
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
|
||||
@@ -61,13 +65,14 @@ void bhv_star_spawn_init(void) {
|
||||
|
||||
void bhv_star_spawn_loop(void) {
|
||||
switch (o->oAction) {
|
||||
case 0:
|
||||
case SPAWN_STAR_ARC_CUTSCENE_ACT_START:
|
||||
o->oFaceAngleYaw += 0x1000;
|
||||
if (o->oTimer > 20)
|
||||
o->oAction = 1;
|
||||
if (o->oTimer > 20) {
|
||||
o->oAction = SPAWN_STAR_ARC_CUTSCENE_ACT_GO_TO_HOME;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case SPAWN_STAR_ARC_CUTSCENE_ACT_GO_TO_HOME:
|
||||
obj_move_xyz_using_fvel_and_yaw(o);
|
||||
o->oStarSpawnVelY += o->oVelY;
|
||||
o->oPosY = o->oStarSpawnVelY + sins((o->oTimer * 0x8000) / 30) * 400.0f;
|
||||
@@ -75,18 +80,21 @@ void bhv_star_spawn_loop(void) {
|
||||
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
|
||||
cur_obj_play_sound_1(SOUND_ENV_STAR);
|
||||
if (o->oTimer == 30) {
|
||||
o->oAction = 2;
|
||||
o->oAction = SPAWN_STAR_ARC_CUTSCENE_ACT_BOUNCE;
|
||||
o->oForwardVel = 0;
|
||||
// Set to exact home coordinates
|
||||
o->oPosX = o->oHomeX;
|
||||
o->oPosZ = o->oHomeZ;
|
||||
play_power_star_jingle(TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (o->oTimer < 20)
|
||||
case SPAWN_STAR_ARC_CUTSCENE_ACT_BOUNCE:
|
||||
if (o->oTimer < 20) {
|
||||
o->oVelY = 20 - o->oTimer;
|
||||
else
|
||||
} else {
|
||||
o->oVelY = -10.0f;
|
||||
|
||||
}
|
||||
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
|
||||
obj_move_xyz_using_fvel_and_yaw(o);
|
||||
o->oFaceAngleYaw = o->oFaceAngleYaw - o->oTimer * 0x10 + 0x1000;
|
||||
@@ -96,11 +104,11 @@ void bhv_star_spawn_loop(void) {
|
||||
cur_obj_play_sound_2(SOUND_GENERAL_STAR_APPEARS);
|
||||
cur_obj_become_tangible();
|
||||
o->oPosY = o->oHomeY;
|
||||
o->oAction = 3;
|
||||
o->oAction = SPAWN_STAR_ARC_CUTSCENE_ACT_END;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case SPAWN_STAR_ARC_CUTSCENE_ACT_END:
|
||||
o->oFaceAngleYaw += 0x800;
|
||||
if (o->oTimer == 20) {
|
||||
gObjCutsceneDone = TRUE;
|
||||
@@ -110,7 +118,7 @@ void bhv_star_spawn_loop(void) {
|
||||
|
||||
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
|
||||
obj_mark_for_deletion(o);
|
||||
o->oInteractStatus = 0;
|
||||
o->oInteractStatus = INT_STATUS_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -128,30 +136,28 @@ struct Object *spawn_star(struct Object *starObj, f32 x, f32 y, f32 z) {
|
||||
void spawn_default_star(f32 x, f32 y, f32 z) {
|
||||
struct Object *starObj = NULL;
|
||||
starObj = spawn_star(starObj, x, y, z);
|
||||
starObj->oBehParams2ndByte = 0;
|
||||
starObj->oBehParams2ndByte = SPAWN_STAR_ARC_CUTSCENE_BP_DEFAULT_STAR;
|
||||
}
|
||||
|
||||
void spawn_red_coin_cutscene_star(f32 x, f32 y, f32 z) {
|
||||
struct Object *starObj = NULL;
|
||||
starObj = spawn_star(starObj, x, y, z);
|
||||
starObj->oBehParams2ndByte = 1;
|
||||
starObj->oBehParams2ndByte = SPAWN_STAR_ARC_CUTSCENE_BP_HIDDEN_STAR;
|
||||
}
|
||||
|
||||
void spawn_no_exit_star(f32 x, f32 y, f32 z) {
|
||||
struct Object *starObj = NULL;
|
||||
starObj = spawn_star(starObj, x, y, z);
|
||||
starObj->oBehParams2ndByte = 1;
|
||||
starObj->oBehParams2ndByte = SPAWN_STAR_ARC_CUTSCENE_BP_HIDDEN_STAR;
|
||||
starObj->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT;
|
||||
}
|
||||
|
||||
void bhv_hidden_red_coin_star_init(void) {
|
||||
s16 numRedCoinsRemaining;
|
||||
struct Object *starObj = NULL;
|
||||
|
||||
if (gCurrCourseNum != COURSE_JRB) {
|
||||
spawn_object(o, MODEL_TRANSPARENT_STAR, bhvRedCoinStarMarker);
|
||||
}
|
||||
numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin);
|
||||
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;
|
||||
@@ -164,12 +170,12 @@ void bhv_hidden_red_coin_star_init(void) {
|
||||
void bhv_hidden_red_coin_star_loop(void) {
|
||||
gRedCoinsCollected = o->oHiddenStarTriggerCounter;
|
||||
switch (o->oAction) {
|
||||
case 0:
|
||||
if (o->oHiddenStarTriggerCounter == 8)
|
||||
o->oAction = 1;
|
||||
case HIDDEN_STAR_ACT_INACTIVE:
|
||||
if (o->oHiddenStarTriggerCounter == 8) {
|
||||
o->oAction = HIDDEN_STAR_ACT_ACTIVE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case HIDDEN_STAR_ACT_ACTIVE:
|
||||
if (o->oTimer > 2) {
|
||||
spawn_red_coin_cutscene_star(o->oPosX, o->oPosY, o->oPosZ);
|
||||
spawn_mist_particles();
|
||||
|
||||
Reference in New Issue
Block a user